EVALUATION
Actually the fix is not as straighforward as it is mention in description,
we should use htmlView.insertElementAt() when the tab is added
and shouldn't insert the new element if the tab's title is updated
when the component is removed BasicTabbedPaneUI
directly removes the element from htmlViews, see Handler.componentRemoved().
So the simplest fix is to do the same when the title is updated,
the new correct element will be inserted by the updateHtmlViews(index) after that
|
|
|
EVALUATION
I reproduced the bug, accepted
Thanks!
|
|
|
EVALUATION
Hi Alex,
to see the problem in your example, just add e.g.:
pane.setTitleAt(0, "<html><b>ONE</b></html>");
So, your createGui() will look:
private static void createGui() {
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTabbedPane pane = new JTabbedPane();
pane.add("one", new JPanel());
pane.add("<html><i>Two</i></html>", new JPanel());
pane.add("three", new JPanel());
pane.setTitleAt(0, "<html><b>ONE</b></html>");
frame.add(pane);
frame.setSize(200, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
The problem is also quite obvious from source code in BasicTabbedPaneUI.Handler.updateHtmlViews() where should be enough to replace
htmlViews.insertElementAt(v, index);
by
htmlViews.setElementAt(v, index);
to fix the problem.
|
|
|
EVALUATION
I created the following test to check the html in tabbedPane
and it works well in JDK 7
asked the submitter for more information
import javax.swing.*;
public class bug6670274 {
private static void createGui() {
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTabbedPane pane = new JTabbedPane();
pane.add("one", new JPanel());
pane.add("<html><i>Two</i></html>", new JPanel());
pane.add("three", new JPanel());
frame.add(pane);
frame.setSize(200, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public static void main(String[] args) throws Exception {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
bug6670274.createGui();
}
});
}
}
|
|
|
|