JDK-4175466 : keyboard navigation in JTabbedPane incorrect under Windows LaF
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0,1.3.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1998-09-22
  • Updated: 2002-03-11
  • Resolved: 2000-04-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 betaFixed
Related Reports
Relates :  
Description

Name: diC59631			Date: 09/22/98


eapHello,

I'm using WinNT v4.0, SP3.

This is a bug that occurs under both JDK v1.2b4.1 and JDK v1.1.6 with
Swing v1.1b2.  There are two problems I've found related to TAB key
navigation using the JTabbedPane under the Windows LaF.  I've attached a
minimal sample program that illustrates these problems

As a reference for standard (i.e., correct) Windows tabbed pane behavior
I would recommend you open MS Word, go under the "Tools" menu and select
the "Options..." menu item.  A two-row tabbed dialog will appear.  You
should use this tabbed dialog as a reference for correct behavior. 
Other (native Windows) tabbed dialogs behave analogously.



Problem 1
---------
When the JTabbedPane is situated such that there are two (or more) rows
of tabs and a tab in the bottom-most row has the focus, pressing the
RIGHT-ARROW (or LEFT-ARROW) key cycles through *ALL* the tabs.  This is
contrary to standard Windows LaF for tabbed panes.  The correct behavior
is to repeatedly cycle through the tabs in the current row only.  The
JTabbedPane, however, continuously repeatedly cycles through *all* the
tabs -- not just the ones in the bottom-most row.

Run the sample program and do this:
1.  Change the LaF to Windows.
2.  Click on the tab labeled "Panel 1".
3.  Repeatedly press the RIGHT-ARROW key.  Notice how the active panel
cycles from panel 1 through panel 9 and then back again.

The correct behavior is for the active panel to repeatedly cycle through
panels 1 through 4 only -- panels 5 through 9 should *not* be activated.



Problem 2
---------
Standard Windows behavior requires that the CTRL-TAB key combination
change the currently active tab in a tabbed pane, regardless of which
control currently has the focus.  The best way to see this is to open
any Windows dialog that contains a tabbed pane (such as the MS Word
"Tools | Options..." dialog).  Pressing the CTRL-TAB key combination
cycles through all the tabs.  The JTabbedPane seems to treat the
CTRL-TAB as a normal TAB.  This is incorrect under the Windows LaF.


Let me know if any of this is not clear.  You can reach me at
602-607-4995.

Regards.


import com.sun.java.swing.*;
import java.awt.event.*;
import java.awt.*;


class Tester {
   public static void main(String[] args) {
      final JFrame      f  = new JFrame();
      final JTabbedPane tabbedPane  = new JTabbedPane();
      final JPanel      panel1 = new JPanel(false),
                        panel2 = new JPanel(false),
                        panel3 = new JPanel(false),                        
                        panel4 = new JPanel(false),
                        panel5 = new JPanel(false),
                        panel6 = new JPanel(false),
                        panel7 = new JPanel(false),
                        panel8 = new JPanel(false),
                        panel9 = new JPanel(false);
                        
      // WindowListener for cosing progam.
      f.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent evt) {
            evt.getWindow().dispose();
            System.exit(0);
         }
      });

      tabbedPane.add("Panel 1", panel1);
      tabbedPane.add("Panel 2", panel2);
      tabbedPane.add("Panel 3", panel3);
      tabbedPane.add("Panel 4", panel4);
      tabbedPane.add("Panel 5", panel5);
      tabbedPane.add("Panel 6", panel6);
      tabbedPane.add("Panel 7", panel7);
      tabbedPane.add("Panel 8", panel8);
      tabbedPane.add("Panel 9", panel9);
      
      f.getContentPane().add(tabbedPane, BorderLayout.CENTER);

      //--------------------
      // The remaining code simply allows for a change in the LaF....
      //--------------------
      JPanel LaFPanel = new JPanel();

      final JButton windowsLaF = new JButton("Windows"),
                    motifLaF   = new JButton("Motif"),
                    metalLaF   = new JButton("Metal");

      LaFPanel.add(windowsLaF);
      LaFPanel.add(motifLaF);
      LaFPanel.add(metalLaF);

      ActionListener LaFListener = new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
            Object src = evt.getSource();

            try {
               if(src == windowsLaF)
                  UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
               else if(src == motifLaF)
      	    	   UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
               else
      	    	   UIManager.setLookAndFeel("com.sun.java.swing.plaf.metal.MetalLookAndFeel");

               SwingUtilities.updateComponentTreeUI(f);
            }
            catch(Exception e) {
               System.err.println("*** ERROR IN CHANGING LAF: " + e);
            }
         }
      };

      windowsLaF.addActionListener(LaFListener);
      motifLaF.addActionListener(LaFListener);
      metalLaF.addActionListener(LaFListener);

      f.getContentPane().add(LaFPanel, BorderLayout.SOUTH);
      f.setResizable(false);
      f.setBounds(40, 40, 330, 200);
      f.setVisible(true);
   }
}
(Review ID: 39192)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin-beta FIXED IN: merlin-beta INTEGRATED IN: merlin-beta
14-06-2004

EVALUATION Name: keC97670 Date: 02/03/2000 Part 1 of this problem is evaluated in 4093898 ###@###.### ====================================================================== Actually, neither of the problems in this report are related to 4093898. Both problems are valid bugs in the JTabbedPane's mouseless implementation. amy.fowler@Eng 2000-03-17 I was able to fix problem#1 easily (just added code that wrapped around runs, instead of shifting to next run). Problem#2 is proving more tricky - even if I add the appropriate actions to handle control-tab and control-shift-tab, the FocusManager seems to be getting in the way and so my actions never get called. amy.fowler@Eng 2000-03-24
24-03-2000