-
Bug
-
Resolution: Unresolved
-
P4
-
7
-
generic
-
generic
JTabbedPane supports tab with null component, however it treats it in a special way.
Swing doesn't allow null component to be added, so the usual machinery with
ContainerListener.componentAdded/componentRemoved doesn't work.
It leads to a situation when html views vector goes unsynchronized when a tab with a null component is removed, so you can see html tags in the tab's title
instead of real html formatting.
import javax.swing.*;
public class MyTest {
private static void createGui() {
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTabbedPane pane = new JTabbedPane();
pane.addTab("Hello", null, null);
// This line would work
// pane.addTab("Hello", null, new JPanel());
pane.addTab("<html><u>underlined text</u></html>", null, null);
pane.removeTabAt(0);
frame.add(pane);
frame.setSize(200, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
MyTest.createGui();
}
});
}
}
Swing doesn't allow null component to be added, so the usual machinery with
ContainerListener.componentAdded/componentRemoved doesn't work.
It leads to a situation when html views vector goes unsynchronized when a tab with a null component is removed, so you can see html tags in the tab's title
instead of real html formatting.
import javax.swing.*;
public class MyTest {
private static void createGui() {
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTabbedPane pane = new JTabbedPane();
pane.addTab("Hello", null, null);
// This line would work
// pane.addTab("Hello", null, new JPanel());
pane.addTab("<html><u>underlined text</u></html>", null, null);
pane.removeTabAt(0);
frame.add(pane);
frame.setSize(200, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
MyTest.createGui();
}
});
}
}
- relates to
-
JDK-6495408 REGRESSION: JTabbedPane throws ArrayIndexOutOfBoundsException
-
- Closed
-