United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4264764 : JButton has wrong margin in a JToolBar with Windows LAF

Details
Type:
Bug
Submit Date:
1999-08-23
Status:
Resolved
Updated Date:
2000-08-03
Project Name:
JDK
Resolved Date:
2000-08-03
Component:
client-libs
OS:
windows_nt
Sub-Component:
javax.swing
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.2.2
Fixed Versions:
1.4.0 (beta)

Related Reports
Relates:
Relates:

Sub Tasks

Description

Name: et89391			Date: 08/23/99


JButtons in a JToolBar with Windows LAF get a margin of 14 pixels for left and right.
This is to much. With Metal LAF everything is fine.
MetalToolBarUI changes the margin of the JButtons in it to (0,0,0,0). See in the source 
lines 231, 260 setBorder...(Component c){..}
The WindowsToolBarUI or its super class BasicToolBarUI does  nothing like this.
I tested and reproduced this behaviour under NT and Win95 with
JDK1.2 and JDK1.2.2.

A similar bug was already reported with the id 4104225. It was
closed because sun couldn't reproduce the bug !!!!?????

Here is my testprogramm:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class  ToolBarTest extends JFrame implements ActionListener{
	Container main;
	JButton metal = new JButton("metal");
	JButton win = new JButton("win");

	public ToolBarTest(){
		main = getContentPane();

		JToolBar tb = new JToolBar();		

		tb.add(
			new AbstractAction("", new ImageIcon("save.gif") ){
				public void actionPerformed(ActionEvent e)
				{
				}
			});

		main.setLayout(new BorderLayout());
		main.add(tb, BorderLayout.NORTH);

		JPanel p = new JPanel(new FlowLayout() );
		
		metal.addActionListener(this);
		win.addActionListener(this);

		p.add(metal);
		p.add(win);

		main.add(p, BorderLayout.SOUTH);

		addWindowListener(new WindowAdapter(){
				public void windowClosing(WindowEvent e){
					System.exit(0);
				}
			});

		setSize(300, 200);
	}
	
	public void actionPerformed(ActionEvent e){
		if( e.getSource() == metal ){
			try{
				UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");	 
				SwingUtilities.updateComponentTreeUI(this);
			}
			catch(Exception e2){
				System.err.println(e2);   
			}		
		}
		else{
			try{
				UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");	 
				SwingUtilities.updateComponentTreeUI(this);
			}
			catch(Exception e1){
				System.err.println(e1);   
			}
		}
	}

	public static void main(String[] args) {
		new ToolBarTest().show();
	}
}


Java vesions:

java full version "JDK-1.2.2-W"
(Review ID: 93883) 
======================================================================

                                    

Comments
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
merlin

FIXED IN:
merlin-beta

INTEGRATED IN:
merlin-beta


                                     
2004-06-14
EVALUATION

According the the MS Windows User Experience (MS Press, 1999), Toolbar buttons should be 16x16. This should be the icon size that we work with for the LAF implementation.

We are going to do another revision of the Window LAF to bring it in line with the current implementation of the Windows UI. Our plan for ToolBars is to remove the border altogether and supprt mouse rollover borders. Also, if we have time, we will support two state buttons in the toolbar with the same LAF behavior as native Windows.

mark.davidson@Eng 2000-04-27

This has been fixed for the next major release. However, you may have to use the rollover buttons client property on the toolbar ("JToolBar.isRollover") to see this. I'll continue to take a look at it make sure that the button borders are correct for non rollover buttons.
mark.davidson@Eng 2000-06-01

This problem has been fixed and integrated.
                                     
2000-06-01



Hardware and Software, Engineered to Work Together