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

Bug while removing lastbutton from JToolBar (or removing all)

    XMLWordPrintable

Details

    Description

      FULL PRODUCT VERSION :
      java version "1.5.0_02"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
      Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 2000 Server 5.00.2195

      A DESCRIPTION OF THE PROBLEM :
      I've got example from Bug ID 4135351 changed import section to make it work on 1.4 release and add the only row toolbar.setPreferredSize(new Dimension(60, 32));.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Press in menu Add JButton 4 times than press Remove JButton

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected that 4 buttons will be added than one-by-one they 'll be removed.
      ACTUAL -
      4 buttons added to toolbar 3 buttons remvoved but after removing the last button the picuture of button left on the tool bar while the button actually removed.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      /**
       * ToolBarTest
       *
       */
      public class ToolBarTest extends JFrame {
          JToolBar toolbar;
          
        public ToolBarTest() {
          super("ToolBarTest");
          setSize(500,500);

          JMenuBar jmb = new JMenuBar();
          JMenu addMenu = new JMenu("Add");
          JMenuItem labelItem = new JMenuItem("Add JButton");

          toolbar = new JToolBar();
          toolbar.setPreferredSize(new Dimension(60, 32));

          labelItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      toolbar.add(new JButton("Test"));
      getContentPane().validate();
      }

          });
          JMenu removeMenu = new JMenu("Remove");
          JMenuItem rItem = new JMenuItem("Remove JButton");
          rItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      toolbar.remove(0);
      getContentPane().validate();
      }

          });

          addMenu.add(labelItem);
          removeMenu.add(rItem);
          jmb.add(addMenu);
          jmb.add(removeMenu);
          setJMenuBar(jmb);

          getContentPane().add(toolbar, "North");
        }

        public static void main(String args[]) {
            ToolBarTest jc = new ToolBarTest();
            jc.setVisible(true);
        }

      }
      ---------- END SOURCE ----------
      ###@###.### 2005-03-16 22:02:04 GMT

      Attachments

        Activity

          People

            shickeysunw Shannon Hickey (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: