}
if (icon != null) {
width += icon.getIconWidth() + _textIconGap;
}
View v = getTextViewForTab(tabIndex);
if (v != null) {
// html
width += (int) v.getPreferredSpan(View.X_AXIS);
}
else {
// plain text
String title = getCurrentDisplayTitleAt(_tabPane, tabIndex);
// while (title == null || title.length() < 3)
// title += " ";
width += SwingUtilities.computeStringWidth(metrics, title);
}
// for gripper
if (_tabPane.isShowGripper()) {
width += _gripperWidth;
}
if (scrollableTabLayoutEnabled() && isShowCloseButton() && isShowCloseButtonOnTab() && _tabPane.isTabClosableAt(tabIndex)) {
if (_tabPane.isShowCloseButtonOnSelectedTab()) {
if (_tabPane.getSelectedIndex() == tabIndex) {
width += _closeButtons[tabIndex].getPreferredSize().width + _closeButtonRightMargin + _closeButtonLeftMargin;
}
}
else {
width += _closeButtons[tabIndex].getPreferredSize().width + _closeButtonRightMargin + _closeButtonLeftMargin;
}
}
// width += _tabRectPadding;
}
else {
Component tabComponent = SystemInfo.isJdk6Above() ? _tabPane.getTabComponentAt(tabIndex) : null;
if (tabComponent != null) {
Insets tabInsets = getTabInsets(tabPlacement, tabIndex);
width = tabComponent.getPreferredSize().width + tabInsets.left + tabInsets.right + 3;
return width;
}
View v = getTextViewForTab(tabIndex);
if (v != null) {
// html
width += (int) v.getPreferredSpan(View.Y_AXIS);
}
else {
// plain text
width += metrics.getHeight();
}