本文整理匯總了Java中java.awt.FocusTraversalPolicy.getLastComponent方法的典型用法代碼示例。如果您正苦於以下問題:Java FocusTraversalPolicy.getLastComponent方法的具體用法?Java FocusTraversalPolicy.getLastComponent怎麽用?Java FocusTraversalPolicy.getLastComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.FocusTraversalPolicy
的用法示例。
在下文中一共展示了FocusTraversalPolicy.getLastComponent方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getLastComponent
import java.awt.FocusTraversalPolicy; //導入方法依賴的package包/類
public Component getLastComponent(Container aContainer) {
Container root = (aContainer.isFocusCycleRoot())
? aContainer
: aContainer.getFocusCycleRootAncestor();
// Support for mixed 1.4/pre-1.4 focus APIs. If a particular root's
// traversal policy is non-legacy, then honor it.
if (root != null) {
FocusTraversalPolicy policy = root.getFocusTraversalPolicy();
if (policy != gluePolicy) {
return policy.getLastComponent(root);
}
comparator.setComponentOrientation(root.getComponentOrientation());
return layoutPolicy.getLastComponent(root);
}
return null;
}
示例2: getLastComponent
import java.awt.FocusTraversalPolicy; //導入方法依賴的package包/類
/**
* Returns the last component.
* @return the last component
* @param aContainer a container
*/
public Component getLastComponent(Container aContainer) {
Container root = (aContainer.isFocusCycleRoot())
? aContainer
: aContainer.getFocusCycleRootAncestor();
// Support for mixed 1.4/pre-1.4 focus APIs. If a particular root's
// traversal policy is non-legacy, then honor it.
if (root != null) {
FocusTraversalPolicy policy = root.getFocusTraversalPolicy();
if (policy != gluePolicy) {
return policy.getLastComponent(root);
}
comparator.setComponentOrientation(root.getComponentOrientation());
return layoutPolicy.getLastComponent(root);
}
return null;
}
示例3: actionPerformed
import java.awt.FocusTraversalPolicy; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent e) {
setFocusCycleRoot(false);
try {
Container con = ETable.this.getFocusCycleRootAncestor();
if (con != null) {
/*
Component target = ETable.this;
if (getParent() instanceof JViewport) {
target = getParent().getParent();
if (target == con) {
target = ETable.this;
}
}
*/
EventObject eo = EventQueue.getCurrentEvent();
boolean backward = false;
if (eo instanceof KeyEvent) {
backward =
(((KeyEvent) eo).getModifiers()
& KeyEvent.SHIFT_MASK)
!= 0 && (((KeyEvent) eo).getModifiersEx() &
KeyEvent.SHIFT_DOWN_MASK) != 0;
}
Component c = ETable.this;
Component to;
Container parentWithFTP = null;
do {
FocusTraversalPolicy ftp = con.getFocusTraversalPolicy();
to = backward ? ftp.getComponentBefore(con, c)
: ftp.getComponentAfter(con, c);
if (to == ETable.this) {
to = backward ? ftp.getFirstComponent(con)
: ftp.getLastComponent(con);
}
if (to == ETable.this) {
parentWithFTP = con.getParent();
if (parentWithFTP != null) {
parentWithFTP = parentWithFTP.getFocusCycleRootAncestor();
}
if (parentWithFTP != null) {
c = con;
con = parentWithFTP;
}
}
} while (to == ETable.this && parentWithFTP != null);
if (to != null) {
to.requestFocus();
}
}
} finally {
setFocusCycleRoot(true);
}
}