本文整理匯總了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;
}