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

JToggleButton jdk 1.4beta, does not toggle when added to JToolbar, windows L&F

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • client-libs
    • beta2
    • x86
    • windows_2000



      Name: bsC130419 Date: 07/13/2001


      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)

      The JToggleButton under jdk 1.4beta does not toggle when added to a JToolbar
      under the windows Look and Feel. It works fine in the metal L&F or inside a
      JPanel container disregarding the L&F.

      Here is the code:

      import java.awt.*;
      import javax.swing.*;
      import java.awt.event.*;

      /**
       * Title:
       * Description:
       * Copyright: Copyright (c) 2001
       * Company: Dunn Solutions Group
       * @author Esteban
       * @version 1.0
       */

      public class TestToggleButton extends JFrame
      {
        JToolBar jToolBar1 = new JToolBar();
        JToggleButton jToggleButton1 = new JToggleButton();
        JPanel jPanel1 = new JPanel();
        JToggleButton jToggleButton2 = new JToggleButton();
        JToggleButton jToggleButton3 = new JToggleButton();
        JToggleButton jToggleButton4 = new JToggleButton();
        JButton jButtonWindows = new JButton();
        JButton jButtonMetal = new JButton();

        public TestToggleButton()
        {
          try
          {
            jbInit();
          }
          catch(Exception e)
          {
            e.printStackTrace();
          }
        }

        public static void main(String args[])
        {
          TestToggleButton test = new TestToggleButton();
          test.pack();
          test.show();
        }
        private void jbInit() throws Exception
        {
          jToggleButton1.setText("jToggleButton1");
          jToggleButton2.setText("jToggleButton2");
          jToggleButton3.setText("jToggleButton3");
          jToggleButton4.setText("jToggleButton4");
          jButtonWindows.setText("Windows");
          jButtonWindows.addActionListener(new java.awt.event.ActionListener()
          {
            public void actionPerformed(ActionEvent e)
            {
              jButtonWindows_actionPerformed(e);
            }
          });
          jButtonMetal.setText("Metal");
          jButtonMetal.addActionListener(new java.awt.event.ActionListener()
          {
            public void actionPerformed(ActionEvent e)
            {
              jButtonMetal_actionPerformed(e);
            }
          });
          this.getContentPane().add(jToolBar1, BorderLayout.NORTH);
          this.getContentPane().add(jPanel1, BorderLayout.CENTER);
          jPanel1.add(jToggleButton2, null);
          jPanel1.add(jToggleButton3, null);
          jToolBar1.add(jToggleButton1, null);
          jToolBar1.add(jToggleButton4, null);
          jToolBar1.add(jButtonWindows, null);
          jToolBar1.add(jButtonMetal, null);
        }

        void jButtonWindows_actionPerformed(ActionEvent e)
        {

          try{
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            SwingUtilities.updateComponentTreeUI(this);
            this.pack();

          }catch(Exception ex){
            ex.printStackTrace();
          }
        }

        void jButtonMetal_actionPerformed(ActionEvent e)
        {
          try{
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName
      ());
            SwingUtilities.updateComponentTreeUI(this);
            this.pack();
          }catch(Exception ex){
            ex.printStackTrace();
          }
        }
      }
      (Review ID: 128050)
      ======================================================================

            mdavidsosunw Mark Davidson (Inactive)
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: