--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java Mon Aug 18 14:03:21 2014 +0100
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java Tue Aug 19 10:32:16 2014 -0700
@@ -1174,6 +1174,16 @@
* this function draws the border around each tab
* note that this function does now draw the background of the tab.
* that is done elsewhere
+ *
+ * @param g the graphics context in which to paint
+ * @param tabPlacement the placement (left, right, bottom, top) of the tab
+ * @param tabIndex the index of the tab with respect to other tabs
+ * @param x the x coordinate of tab
+ * @param y the y coordinate of tab
+ * @param w the width of the tab
+ * @param h the height of the tab
+ * @param isSelected a {@code boolean} which determines whether or not
+ * the tab is selected
*/
protected void paintTabBorder(Graphics g, int tabPlacement,
int tabIndex,
@@ -3530,12 +3540,7 @@
else if (name =="indexForTitle") {
calculatedBaseline = false;
Integer index = (Integer) e.getNewValue();
- // remove the current index
- // to let updateHtmlViews() insert the correct one
- if (htmlViews != null) {
- htmlViews.removeElementAt(index);
- }
- updateHtmlViews(index);
+ updateHtmlViews(index, false);
} else if (name == "tabLayoutPolicy") {
BasicTabbedPaneUI.this.uninstallUI(pane);
BasicTabbedPaneUI.this.installUI(pane);
@@ -3574,13 +3579,13 @@
calculatedBaseline = false;
} else if (name == "indexForNullComponent") {
isRunsDirty = true;
- updateHtmlViews((Integer)e.getNewValue());
+ updateHtmlViews((Integer)e.getNewValue(), true);
} else if (name == "font") {
calculatedBaseline = false;
}
}
- private void updateHtmlViews(int index) {
+ private void updateHtmlViews(int index, boolean inserted) {
String title = tabPane.getTitleAt(index);
boolean isHTML = BasicHTML.isHTMLString(title);
if (isHTML) {
@@ -3588,16 +3593,24 @@
htmlViews = createHTMLVector();
} else { // Vector already exists
View v = BasicHTML.createHTMLView(tabPane, title);
- htmlViews.insertElementAt(v, index);
+ setHtmlView(v, inserted, index);
}
} else { // Not HTML
if (htmlViews!=null) { // Add placeholder
- htmlViews.insertElementAt(null, index);
+ setHtmlView(null, inserted, index);
} // else nada!
}
updateMnemonics();
}
+ private void setHtmlView(View v, boolean inserted, int index) {
+ if (inserted || index >= htmlViews.size()) {
+ htmlViews.insertElementAt(v, index);
+ } else {
+ htmlViews.setElementAt(v, index);
+ }
+ }
+
//
// ChangeListener
//
@@ -3716,7 +3729,7 @@
return;
}
isRunsDirty = true;
- updateHtmlViews(tp.indexOfComponent(child));
+ updateHtmlViews(tp.indexOfComponent(child), true);
}
public void componentRemoved(ContainerEvent e) {
JTabbedPane tp = (JTabbedPane)e.getContainer();