JDK-4264764 : JButton has wrong margin in a JToolBar with Windows LAF
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.2
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1999-08-23
  • Updated: 2000-08-03
  • Resolved: 2000-08-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 betaFixed
Related Reports
Relates :  
Relates :  
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
14-06-2004

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.
01-06-2000