Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6739756

JToolBar leaves space for non-visible items under Nimbus L&F

XMLWordPrintable

    • b04
    • x86
    • windows_xp
    • Verified

        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.

              alexp Alexander Potochkin (Inactive)
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: