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

setVisible(false) on Jbutton is a Jtoolbar with gtk laf does not work

XMLWordPrintable

      FULL PRODUCT VERSION :
      Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
      Java(TM) SE Runtime Environment (build 1.7.0-ea-b13)
      Java(TM) SE Runtime Environment (build 1.6.0_02-ea-b02)




      ADDITIONAL OS VERSION INFORMATION :
      The issue occurs on:
      - Debian Etch/Lenny
      - Ubuntu Edgy/Feisty

      A DESCRIPTION OF THE PROBLEM :
      On linux, when a set the gtk and feel; if I add a JButton to a JToolbar and I call button.setVisible(false), then the space taken by the button is not released in the toolbar.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      import java.awt.Dimension;
      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JToolBar;
      import javax.swing.UIManager;
       
       
      public class PanelTest extends JFrame
      {
      public static void main(String[] args)
      {
      try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); } catch (Exception e) { /* */ }

      PanelTest pt = new PanelTest();
      pt.setVisible(true);
      }


      public PanelTest()
      {
      JToolBar p = new JToolBar();
      JButton b1 = new JButton("test1");
      JButton b2 = new JButton("test2");
      JButton b3 = new JButton("test3");
       
      p.add(b1);
      p.add(b2);
      p.add(b3);

      b2.setVisible(false);
       
      getContentPane().add(p);
      pack();
      }
      }



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The space taken by the button "b2" should be release and the position of the two remained buttons should be updated.
      ACTUAL -
      The space between "b1" and "b3" is not released when the button "b2" is hidden. The position of the two remained buttons is not updated.

      REPRODUCIBILITY :
      This bug can be reproduced always.

            Unassigned Unassigned
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: