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

button is activated as "default" even when not showing (in JTabbedPane)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.3.0
    • client-libs
    • beta
    • x86
    • windows_nt



      Name: mc57594 Date: 12/09/99


      reproduced on Solaris 2.7 with jdk1.3 beta

      [chamness]
      =-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=

      java version "1.2.2"
      HotSpot VM (1.0fcs, mixed mode, build E)

      SOURCE CODE:
      //////////////////////////////////
      package TabPanelTest;

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

      public class Test implements ActionListener {
        private JTabbedPane jTabbedPane1 = new JTabbedPane();
        private JButton testButton = new JButton( "Test" );
        private JFrame testFrame = new JFrame();
        private JPanel testTab1 = new JPanel();
        private JPanel testTab2 = new JPanel();
        private JPanel testTab3 = new JPanel();


        public Test() {
          jbInit();
          testFrame.setSize( 200, 300 );
          testFrame.setVisible( true );
        }

        public static void main(String[] args) {
          try {
            javax.swing.UIManager.setLookAndFeel(
              "com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
          } catch (Exception e) {
            e.printStackTrace();
          }
          new Test();
        }

        private void jbInit() {
          testFrame.getContentPane().add( jTabbedPane1, BorderLayout.CENTER );
          //add panels to tab pane
          jTabbedPane1.add( "TAB 1", testTab1 );
          jTabbedPane1.add( "TAB 2", testTab2 );
          jTabbedPane1.add( "TAB 3", testTab3 );

          testTab1.setLayout( new BorderLayout( ) );
          testTab1.add( testButton, BorderLayout.SOUTH );

          testButton.addActionListener( this );

        }

        public void actionPerformed( ActionEvent e ) {
           if( e.getSource() == testButton )
            System.out.println( "Button pressed !!!" );
        }
      }
      //////////////////////////////////////////////////////////////////
      At the beginning after frame is opened ( focus is on first tab ) I press on test
      button, after this I pass to other tab and press on Enter key and see that
      actionParformed() of test button is invoked despite of FIRST TAB IS NOT IN FOCUS
      NOW.
      (Review ID: 98751)
      ======================================================================

            amfowler Anne Fowler (Inactive)
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: