-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0
-
x86
-
windows_2000
###@###.### 2001-09-25
It might be related to bug#4190719; old bug not been addressed.
J2SE Version (please include all output from java -version flag):
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b78)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b78, mixed mode)
Does this problem occur on J2SE 1.3? Yes / No (pick one)
Yes
Operating System Configuration Information (be specific):
Windows 2000 (Korean) SP2 with IE 6.0
(Same problem can be reproduced on Solaris as well)
Hardware Configuration Information (be specific):
PIII 650MHz / RAM 256MB / ATI video card Rage 128 GL
Bug Description:
Component is hidden when removing and then readding it to the same
JTabbedPane.
Steps to Reproduce (be specific):
It's simple to reproduce. Run the code listed in the end of this report.
If you want to fix it, you should uncomment the codes surrounded by /* ... */.
This is caused by the fact that the visibility changes occurred
by adding or removing a tab are done by the LayoutManager of JTabbedPane.
Look at the BasicTabbedPaneUI class. The setVisibieComponent(..) is
the main cause of this bug.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test {
public static void main(String[] argv) {
final JTabbedPane tp = new JTabbedPane();
final JPanel p = new JPanel();
p.add(new JLabel("Can't you see me?"));
JFrame f = new JFrame();
f.setBounds(100, 100, 500, 500);
f.getContentPane().add(tp);
tp.addTab("Original", p);
JButton b = new JButton("Add");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
tp.remove(0);
/*
SwingUtilities.invokeLater(new Runnable() {
public void run() {
*/
tp.addTab("New", p);
/*
}
});
*/
}
});
f.getContentPane().add(b, BorderLayout.SOUTH);
f.setVisible(true);
}
}
- duplicates
-
JDK-4190719 JTabbedPane can fail to display selected component
-
- Resolved
-