United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6739756 JToolBar leaves space for non-visible items under Nimbus L&F
JDK-6739756 : JToolBar leaves space for non-visible items under Nimbus L&F

Details
Type:
Bug
Submit Date:
2008-08-21
Status:
Closed
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2009-05-18
Component:
client-libs
OS:
windows_xp
Sub-Component:
javax.swing
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
6u10
Fixed Versions:
6u14 (b04)

Related Reports
Backport:
Relates:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.6.0_10-rc"
Java(TM) SE Runtime Environment (build 1.6.0_10-rc-b28)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
Unlike other Look & Feels, Nimbus leaves space for non-visible items in a JToolBar.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect the "Test" and "Test3" buttons to be adjacent.
ACTUAL -
"Test" and "Test3" buttons are separated by space allocated for non-visible "Test2" button.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;

public class NimbusToolBarBug extends JFrame {
	 
   public static void main(String[] args) {
      try {
         UIManager.setLookAndFeel(
                 "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
      }
      catch (Exception e) {
      }
     
      JDialog dg = new JDialog();
      JToolBar tb = new JToolBar();
      tb.add(new JButton("Test"));
      JButton b2 = new JButton("Test2");
      b2.setVisible(false);
      tb.add(b2);
      tb.add(new JButton("Test3"));
      dg.add(tb);
      dg.pack();
      dg.setVisible(true);
   }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
For all items added to the JToolBar which might ever be non-visible, use item subclasses for which the preferred size is (0,0) when the item is not visible.

                                    

Comments
EVALUATION

We should fix the default layout for SynthToolBarUI
                                     
2009-03-04



Hardware and Software, Engineered to Work Together