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

1.4.2 REGRESSION: Rollover mode in JToolBar is lost after first switching L&F

XMLWordPrintable

    • tiger
    • generic, x86
    • generic, linux, windows_2000, windows_xp



      Name: jk109818 Date: 07/07/2003


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

      FULL OS VERSION :
      Microsoft Windows 2000 [Version 5.00.2195] SP3

      A DESCRIPTION OF THE PROBLEM :
      After first changing L&F the rollover mode in JToolBar is lost

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Execute attached program
      2) Try to switch L&F by clicking buttons

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Rollover mode is remain working
      ACTUAL -
      After first switching the rollover mode is lost

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class RolloverBug
      {
       static void setLAF(String lafName)
       {
        try
          {
           UIManager.setLookAndFeel( lafName );

           Frame[] frames = Frame.getFrames();

           for( int i=0; i<frames.length; i++ )
             {
              SwingUtilities.updateComponentTreeUI( frames[i] );
             }
          }
        catch(Exception ex)
          {
           ex.printStackTrace();
          }
       }

       public static void main(String s[])
       {
        JFrame frame = new JFrame();

        JToolBar bar = new JToolBar(JToolBar.HORIZONTAL);

        bar.setRollover(true);

        UIManager.LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels();

        for( int i=0; i<lafs.length; i++ )
          {
           final String name = lafs[i].getName();
           final String className = lafs[i].getClassName();

           bar.add( new AbstractAction(name)
             {
              public void actionPerformed(ActionEvent evt) { setLAF(className); }
             });
          }

        frame.getContentPane().add(bar,BorderLayout.NORTH);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        frame.pack();

        frame.setVisible(true);
       }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Recreating JToolBar after switching L&F. Calling again setRollover(true) do not help.

      Release Regression From : 1.4.1
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Review ID: 189735)
      ======================================================================

      Name: jk109818 Date: 07/07/2003


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

      FULL OS VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      A JToolBar created with the rollover effect loses the rollover effect after calling SwingUtilities.updateComponentTreeUI() on the parent frame.

      NOTE: This bug occurs with the JDK1.4.2 *release* version, as well as the beta-version. Your bug database system only allowed me to choose v.1.4.2-beta in the Java "Release" choice box.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the sample program.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expect to get a toolbar with a rollover button.
      ACTUAL -
      I get a toolbar with a static border drawn around the toolbar button.

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class Rollover
      {
        public static void main(String[] args)
        {
          JButton button = new JButton("Exit");
          button.addActionListener(new ActionListener()
          {
            public void actionPerformed(ActionEvent e)
            {
              System.exit(0);
            }
          });

        JToolBar toolBar = new JToolBar();
        toolBar.setRollover(true);
        toolBar.add(button);

        JFrame frame = new JFrame();
        frame.getContentPane().add(toolBar, BorderLayout.NORTH);
        frame.pack();
        frame.setVisible(true);

        // This line causes the problem
        SwingUtilities.updateComponentTreeUI(frame);
        }
      }
      ---------- END SOURCE ----------
      (Review ID: 190132)
      ======================================================================

            leifs Leif Samuelsson (Inactive)
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: