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

Nimbus JToolBar border or margin is not reset after Look & Feel change

    XMLWordPrintable

    Details

      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 :
      The border or margin for a JToolBar created under Nimbus Look and Feel is different from one created under Metal and then switched to Nimbus. I didn't investigate to find the exact problem, but the apparent border/margin size is different.

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

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The two dialogs should be the same size.
      ACTUAL -
      The dialog created under Metal then switched to Nimbus is larger, because the JToolBar it contains has a larger margin or border, or some other layout difference, from the one created under Nimbus.

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class NimbusToolBarBug2 extends JFrame {
       
         public static void main(String[] args) {
            try {
               UIManager.setLookAndFeel(
                     "javax.swing.plaf.metal.MetalLookAndFeel");
            }
            catch (Exception e) {
            }
            final JDialog dg = new JDialog();
            JToolBar tb = new JToolBar();
            tb.add(new JButton("Test"));
            dg.add(tb);
            dg.pack();
            dg.setVisible(true);
         
            SwingUtilities.invokeLater(
               new Runnable() {
                  public void run() {
                     try {
                        UIManager.setLookAndFeel(
                           "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
                     }
                     catch (Exception e) {
                     }
                     SwingUtilities.updateComponentTreeUI(dg);
                     JDialog dg2 = new JDialog();
                     JToolBar tb = new JToolBar();
                     tb.add(new JButton("Test"));
                     dg2.add(tb);
                     dg2.pack();
                     dg2.setVisible(true);
                  }
               });
         }
      }

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

        Attachments

          Activity

            People

            Assignee:
            peterz Peter Zhelezniakov
            Reporter:
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Imported:
              Indexed: