JDK-4268306 : JToolBar uses wrong interior padding w/ Windows LF
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.2
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 1999-09-02
  • 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
Description

Name: wl91122			Date: 09/02/99


When compared to the native look and feel of Windows apps, the
JToolBar's interior padding(ie the distance from its border to
the buttons contained in it) is incorrect. You can see this by
comparing a native Windows app that doesn't have the rollover
toolbar effect(like WordPad) to one created using Swing. The
code below creates a simple toolbar with three buttons. On a 
native Windows app the interior padding is roughly 3 pixels above
and below the contained buttons and 4 pixels on the far left
and right(these are eye-balled). The JToolBar, using the Windows
LF doesn't provide any padding, which makes it different from the
the native appearance it's suppose to be emulating.

When invoking the test app if you don't supply any command-line
args the LF is Metal. If any args are supplied the LF is Windows.

Here's the code:

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

public class bug extends JFrame {

    public static void main(String args[]) {
        if (args.length > 0) {
            try {
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            } catch (Exception e) {}
        }
        new bug();
    }
    public bug() {

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

        JToolBar toolbar = new JToolBar();
        toolbar.add(new JButton("Button1"));
        toolbar.add(new JButton("Button2"));
        toolbar.add(new JButton("Button3"));

        getContentPane().add(toolbar, BorderLayout.NORTH);
        pack();
        setSize(300,100);
        setVisible(true);
    }
}
(Review ID: 94800) 
======================================================================

Name: krT82822			Date: 09/27/99


In my program i use abstract actions to create my buttons which
are added to a toolbar. When using the metal look and feel, the
buttons in the toolbar are squares (the used icons are all
16 * 16 pixels in size). But when using the windows
look and feel they are much wider than high. Even when setting
the margin with the setMargin method of button, the problem is
not resolved because this method seems not to work properly
(at least for the vertical margin).

This is how i create my buttons and the toolbar
...
JToolBar toolBar = new JToolBar();
Action act;
JButton button;
button = toolBar.add(act);
...
(Review ID: 95766)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: merlin-beta INTEGRATED IN: merlin-beta
14-06-2004

WORK AROUND Name: wl91122 Date: 09/02/99 You can manually set the toolbar border to use a compound border, where the inner border is empty and is set to use the appropriate top,left,bottom,right padding. ======================================================================
11-06-2004

EVALUATION This has been fixed as part of the revision to the Windows Look and Feel. The ToolBarBorder class was added to WindowsBorders. mark.davidson@Eng 2000-08-02
02-08-2000