本文整理汇总了Java中javax.swing.JTabbedPane.getUI方法的典型用法代码示例。如果您正苦于以下问题:Java JTabbedPane.getUI方法的具体用法?Java JTabbedPane.getUI怎么用?Java JTabbedPane.getUI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTabbedPane
的用法示例。
在下文中一共展示了JTabbedPane.getUI方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeTabVisible
import javax.swing.JTabbedPane; //导入方法依赖的package包/类
private boolean makeTabVisible(JTabbedPane tp, int selectedTab) {
validateTab();
if (!(tp.getUI() instanceof BasicTabbedPaneUI)) {
try {
EventQueueWait.call(tp, "setSelectedIndex", selectedTab);
} catch (NoSuchMethodException e) {
throw new InvalidElementStateException(
"Unable to call setSelectedIndex on JTabbedPane. selectedTab = " + selectedTab, e);
}
return true;
}
boolean isVisible = false;
int n = tp.getTabCount();
int loopCount = n;
Action backward = tp.getActionMap().get("scrollTabsBackwardAction");
Action forward = tp.getActionMap().get("scrollTabsForwardAction");
while (!isVisible && loopCount-- > 0) {
int firstVisibleTab = -1, lastVisibleTab = -1;
for (int i = 0; i < n; i++) {
Rectangle tabBounds = tp.getBoundsAt(i);
int tabForCoordinate = tp.getUI().tabForCoordinate(tp, tabBounds.x + tabBounds.width / 2,
tabBounds.y + tabBounds.height / 2);
if (tabForCoordinate != -1) {
if (firstVisibleTab == -1) {
firstVisibleTab = tabForCoordinate;
}
lastVisibleTab = tabForCoordinate;
}
}
isVisible = firstVisibleTab <= selectedTab && selectedTab <= lastVisibleTab;
if (isVisible) {
continue;
}
if (selectedTab < firstVisibleTab) {
backward.actionPerformed(new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, ""));
} else {
forward.actionPerformed(new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, ""));
}
}
return isVisible;
}