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

JToolBar cannot reset rollover border when removed from it's parent container

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 1.4.2
    • client-libs
    • beta
    • x86
    • windows_2000



      Name: gm110360 Date: 05/06/2004


      FULL PRODUCT VERSION :
      java version "1.4.2_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06)
      Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)


      A DESCRIPTION OF THE PROBLEM :
      Create a JToolBar and use it's rollover mode, press a button on the JToolBar and then remove the JToolBar from it's parent container, the JToolBar cannot change the button border, the border of that button remain rollover border, when add the JToolBar to it's parent container again, the border of that button remain rollover border.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See test case class comment

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The JToolBar should reset all button border when removed from it's parent container.
      ACTUAL -
      The JToolBar do nothing when removed from it's parent container.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /**
       * 1.create a ToolBarBug.java file.
       * 2.javac ToolBarBug.java
       * 3.java ToolBarBug
       * 4.Press one button on JToolBar
       * 5.Press the "show the toolbar" button.
       */
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.event.*;

      public class ToolBarBug extends JPanel {
      private JToolBar toolBar;
      public ToolBarBug() {
      setLayout(new BorderLayout());
      add(createToolBar(), BorderLayout.NORTH);
      add(createSouthPanel(), BorderLayout.SOUTH);
      }
      private JToolBar createToolBar() {
      toolBar = new JToolBar();
      toolBar.setRollover(true);
      for(int i=0; i<5; i++) {
      JButton b = new JButton(""+i);
      b.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      remove(toolBar);
      revalidate();
      repaint();
      }
      });
      toolBar.add(b);
      }
      return toolBar;
      }
      private JPanel createSouthPanel() {
      JPanel p = new JPanel();
      JButton b = new JButton("show the toolbar");
      b.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      add(toolBar, BorderLayout.NORTH);
      revalidate();
      repaint();
      }
      }
      );
      p.add(b);
      return p;
      }
      public static void main(String[] args) {
      JFrame f = new JFrame();
      f.getContentPane().add(new ToolBarBug());
      f.setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE);
      f.pack();
      centerOnScreen(f);
      f.show();
          }

          private static void centerOnScreen(Window window) {
      Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
      window.setLocation((d.width - window.getWidth())/2,
      (d.height - window.getHeight())/2);
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      After JToolBar hide, invoke setRollover(false) and setRollover(true) will solve this problem, but I think this should be handle in JToolBar UI class.

      Add a ComponentListener in JToolBar UI class and reset all Button border when JToolBar has removed from it's parent container.
      (Incident Review ID: 260512)
      ======================================================================

            alexp Alexander Potochkin (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: