United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4268306 : JToolBar uses wrong interior padding w/ Windows LF

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

Related Reports

Sub Tasks

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


                                     
2004-06-14
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.
======================================================================
                                     
2004-06-11
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
                                     
2000-08-02



Hardware and Software, Engineered to Work Together