Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4268306
Votes 1
Synopsis JToolBar uses wrong interior padding w/ Windows LF
Category java:classes_swing
Reported Against 1.2.2
Release Fixed 1.4(merlin-beta)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs
Submit Date 02-SEP-1999
Description




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) 
======================================================================




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)
======================================================================
Work Around




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.
======================================================================
Evaluation
This has been fixed as part of the revision to the Windows Look and Feel. The ToolBarBorder class was added to WindowsBorders.
 xxxxx@xxxxx  2000-08-02
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang