1172 |
1172 |
1173 /** |
1173 /** |
1174 * this function draws the border around each tab |
1174 * this function draws the border around each tab |
1175 * note that this function does now draw the background of the tab. |
1175 * note that this function does now draw the background of the tab. |
1176 * that is done elsewhere |
1176 * that is done elsewhere |
|
1177 * |
|
1178 * @param g the graphics context in which to paint |
|
1179 * @param tabPlacement the placement (left, right, bottom, top) of the tab |
|
1180 * @param tabIndex the index of the tab with respect to other tabs |
|
1181 * @param x the x coordinate of tab |
|
1182 * @param y the y coordinate of tab |
|
1183 * @param w the width of the tab |
|
1184 * @param h the height of the tab |
|
1185 * @param isSelected a {@code boolean} which determines whether or not |
|
1186 * the tab is selected |
1177 */ |
1187 */ |
1178 protected void paintTabBorder(Graphics g, int tabPlacement, |
1188 protected void paintTabBorder(Graphics g, int tabPlacement, |
1179 int tabIndex, |
1189 int tabIndex, |
1180 int x, int y, int w, int h, |
1190 int x, int y, int w, int h, |
1181 boolean isSelected ) { |
1191 boolean isSelected ) { |
3528 pane.repaint(); |
3538 pane.repaint(); |
3529 } |
3539 } |
3530 else if (name =="indexForTitle") { |
3540 else if (name =="indexForTitle") { |
3531 calculatedBaseline = false; |
3541 calculatedBaseline = false; |
3532 Integer index = (Integer) e.getNewValue(); |
3542 Integer index = (Integer) e.getNewValue(); |
3533 // remove the current index |
3543 updateHtmlViews(index, false); |
3534 // to let updateHtmlViews() insert the correct one |
|
3535 if (htmlViews != null) { |
|
3536 htmlViews.removeElementAt(index); |
|
3537 } |
|
3538 updateHtmlViews(index); |
|
3539 } else if (name == "tabLayoutPolicy") { |
3544 } else if (name == "tabLayoutPolicy") { |
3540 BasicTabbedPaneUI.this.uninstallUI(pane); |
3545 BasicTabbedPaneUI.this.uninstallUI(pane); |
3541 BasicTabbedPaneUI.this.installUI(pane); |
3546 BasicTabbedPaneUI.this.installUI(pane); |
3542 calculatedBaseline = false; |
3547 calculatedBaseline = false; |
3543 } else if (name == "tabPlacement") { |
3548 } else if (name == "tabPlacement") { |
3572 tabPane.revalidate(); |
3577 tabPane.revalidate(); |
3573 tabPane.repaint(); |
3578 tabPane.repaint(); |
3574 calculatedBaseline = false; |
3579 calculatedBaseline = false; |
3575 } else if (name == "indexForNullComponent") { |
3580 } else if (name == "indexForNullComponent") { |
3576 isRunsDirty = true; |
3581 isRunsDirty = true; |
3577 updateHtmlViews((Integer)e.getNewValue()); |
3582 updateHtmlViews((Integer)e.getNewValue(), true); |
3578 } else if (name == "font") { |
3583 } else if (name == "font") { |
3579 calculatedBaseline = false; |
3584 calculatedBaseline = false; |
3580 } |
3585 } |
3581 } |
3586 } |
3582 |
3587 |
3583 private void updateHtmlViews(int index) { |
3588 private void updateHtmlViews(int index, boolean inserted) { |
3584 String title = tabPane.getTitleAt(index); |
3589 String title = tabPane.getTitleAt(index); |
3585 boolean isHTML = BasicHTML.isHTMLString(title); |
3590 boolean isHTML = BasicHTML.isHTMLString(title); |
3586 if (isHTML) { |
3591 if (isHTML) { |
3587 if (htmlViews==null) { // Initialize vector |
3592 if (htmlViews==null) { // Initialize vector |
3588 htmlViews = createHTMLVector(); |
3593 htmlViews = createHTMLVector(); |
3589 } else { // Vector already exists |
3594 } else { // Vector already exists |
3590 View v = BasicHTML.createHTMLView(tabPane, title); |
3595 View v = BasicHTML.createHTMLView(tabPane, title); |
3591 htmlViews.insertElementAt(v, index); |
3596 setHtmlView(v, inserted, index); |
3592 } |
3597 } |
3593 } else { // Not HTML |
3598 } else { // Not HTML |
3594 if (htmlViews!=null) { // Add placeholder |
3599 if (htmlViews!=null) { // Add placeholder |
3595 htmlViews.insertElementAt(null, index); |
3600 setHtmlView(null, inserted, index); |
3596 } // else nada! |
3601 } // else nada! |
3597 } |
3602 } |
3598 updateMnemonics(); |
3603 updateMnemonics(); |
|
3604 } |
|
3605 |
|
3606 private void setHtmlView(View v, boolean inserted, int index) { |
|
3607 if (inserted || index >= htmlViews.size()) { |
|
3608 htmlViews.insertElementAt(v, index); |
|
3609 } else { |
|
3610 htmlViews.setElementAt(v, index); |
|
3611 } |
3599 } |
3612 } |
3600 |
3613 |
3601 // |
3614 // |
3602 // ChangeListener |
3615 // ChangeListener |
3603 // |
3616 // |
3714 Component child = e.getChild(); |
3727 Component child = e.getChild(); |
3715 if (child instanceof UIResource) { |
3728 if (child instanceof UIResource) { |
3716 return; |
3729 return; |
3717 } |
3730 } |
3718 isRunsDirty = true; |
3731 isRunsDirty = true; |
3719 updateHtmlViews(tp.indexOfComponent(child)); |
3732 updateHtmlViews(tp.indexOfComponent(child), true); |
3720 } |
3733 } |
3721 public void componentRemoved(ContainerEvent e) { |
3734 public void componentRemoved(ContainerEvent e) { |
3722 JTabbedPane tp = (JTabbedPane)e.getContainer(); |
3735 JTabbedPane tp = (JTabbedPane)e.getContainer(); |
3723 Component child = e.getChild(); |
3736 Component child = e.getChild(); |
3724 if (child instanceof UIResource) { |
3737 if (child instanceof UIResource) { |