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

JTabbedPane setSelectedIndex(-1) doesn't work properly with Scroll Layout

XMLWordPrintable

    • b34
    • x86
    • windows_2000



      Name: rmT116609 Date: 07/21/2004


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

      java version "1.5.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
      Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      JTabbedPane setSelectedIndex(-1) doesn't work properly with Scroll Layout

      When using SCROLL_TAB_LAYOUT JTabbedPane setSelectedIndex(-1) causes no tabs to be displayed, hence they can't be selected. With WRAP_TAB_LAYOUT it does display the tabs.

        See also bug 4435617 which states that JTabbedPane was already meant to have been fixed such that setSelectedIndex(-1) does clear the selected tab (not make it invisible such that it can't be selected again).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      tabs to appear as they do with WRAP_TAB_LAYOUT
      ACTUAL -
      tabs don't appear

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;

      public class Test {
        public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
            public void run() {
              JTabbedPane pane = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
              pane.addTab("Test", new JLabel("Test"));
              pane.setSelectedIndex(-1);
              JFrame frame = new JFrame();
              frame.getContentPane().add(pane);
              frame.setSize(500, 500);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setVisible(true);
            }
          });
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      use WRAP_TAB_LAYOUT instead of SCROLL_TAB_LAYOUT
      (Incident Review ID: 233797)
      ======================================================================

            alexp Alexander Potochkin (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: