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

JTabbedPaneUI component removing bug

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • client-libs



      Name: bsC130419 Date: 07/12/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)

      While working with JTabbedPane, we traced a bug -

      BUG
      If we remove selected component from JTabbedPane and try to put the removed
      component in any other container, then that container doesn?t show the removed
      component.

      REASON
      While selecting any component in it, JTabbedPane sets the last selected
      component?s visible state to false (setVisible (false) ) and sets new selected
      component?s visible state to true. Same behavior is seen at the time of
      removing any component i.e. removed component?s visible state is set to false.


      PROBLEM AREA
      This call for setVisible(false) of removed component is from line number 789 of
      BasicTabbedPaneUI.java class

      SOLUTION
        To remove this bug, in BasicTabbedPaneUI.java class, while checking for whether
      visibleComponent is null or not, there should be one check more to see whether
      visibleComponent?s parent is this JTabbedPane or not. As visibleComponent after
      removing is not a child of this JTabbedPane, then visibleComponent.setVisible
      (false) should not be called.



      // TEST PROGRAM


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

      public class TestJTabbedPane extends JFrame {
          JTabbedPane tp = new JTabbedPane();
          JButton jb = new JButton(" JButton ");
          JLabel label = new JLabel(" JLabel " ,JLabel.CENTER);

          public TestJTabbedPane() {
              addWindowListener(new WindowAdapter(){
                  public void windowClosing(WindowEvent e){
                      System.exit(0);
                  }
              });


              tp.addTab(" JButton " , jb);
              tp.addTab(" JLabel " , label);


              getContentPane().add(tp);

              tp.addKeyListener(new KeyAdapter(){
                  public void keyPressed(KeyEvent e){
                          getContentPane().add(jb, BorderLayout.SOUTH);
                  }
              });

              setSize(500,400);
          }

          public static void main(String[] args) {
              TestJTabbedPane testTabbedPane = new TestJTabbedPane();
              testTabbedPane.setVisible(true);
          }
      }
      (Review ID: 127926)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: