本文整理汇总了Java中java.awt.Container.getFocusTraversalPolicy方法的典型用法代码示例。如果您正苦于以下问题:Java Container.getFocusTraversalPolicy方法的具体用法?Java Container.getFocusTraversalPolicy怎么用?Java Container.getFocusTraversalPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Container
的用法示例。
在下文中一共展示了Container.getFocusTraversalPolicy方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import java.awt.Container; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
int selIndexBefore = getSelectedIndex();
defaultAction.actionPerformed( e );
int selIndexCurrent = getSelectedIndex();
if( selIndexBefore != selIndexCurrent )
return;
if( focusNext && 0 == selIndexCurrent && getModel().getSize() > 1 && getModel().getSize() > getColumnCount() )
return;
KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
Container container = kfm.getCurrentFocusCycleRoot();
FocusTraversalPolicy policy = container.getFocusTraversalPolicy();
if( null == policy )
policy = kfm.getDefaultFocusTraversalPolicy();
Component next = focusNext ? policy.getComponentAfter( container, CategoryList.this )
: policy.getComponentBefore( container, CategoryList.this );
if( null != next && next instanceof CategoryButton ) {
clearSelection();
next.requestFocus();
}
}
示例2: focusSpinnerIfNecessary
import java.awt.Container; //导入方法依赖的package包/类
/**
* Requests focus on a child of the spinner if the spinner doesn't have
* focus.
*/
private void focusSpinnerIfNecessary()
{
Component fo = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if( spinner.isRequestFocusEnabled() && (fo == null || !SwingUtilities.isDescendingFrom(fo, spinner)) )
{
Container root = spinner;
if( !root.isFocusCycleRoot() )
{
root = root.getFocusCycleRootAncestor();
}
if( root != null )
{
FocusTraversalPolicy ftp = root.getFocusTraversalPolicy();
Component child = ftp.getComponentAfter(root, spinner);
if( child != null && SwingUtilities.isDescendingFrom(child, spinner) )
{
child.requestFocus();
}
}
}
}
示例3: getComponentAfter
import java.awt.Container; //导入方法依赖的package包/类
public Component getComponentAfter(Container aContainer,
Component aComponent)
{
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.getComponentAfter(root, aComponent);
}
comparator.setComponentOrientation(root.getComponentOrientation());
return layoutPolicy.getComponentAfter(root, aComponent);
}
return null;
}
示例4: getComponentBefore
import java.awt.Container; //导入方法依赖的package包/类
public Component getComponentBefore(Container aContainer,
Component aComponent)
{
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.getComponentBefore(root, aComponent);
}
comparator.setComponentOrientation(root.getComponentOrientation());
return layoutPolicy.getComponentBefore(root, aComponent);
}
return null;
}
示例5: getFirstComponent
import java.awt.Container; //导入方法依赖的package包/类
public Component getFirstComponent(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.getFirstComponent(root);
}
comparator.setComponentOrientation(root.getComponentOrientation());
return layoutPolicy.getFirstComponent(root);
}
return null;
}
示例6: getLastComponent
import java.awt.Container; //导入方法依赖的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;
}
示例7: getComponentAfter
import java.awt.Container; //导入方法依赖的package包/类
/**
* Returns the component after.
* @return the component after
* @param aContainer a container
* @param aComponent a component
*/
public Component getComponentAfter(Container aContainer,
Component aComponent)
{
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.getComponentAfter(root, aComponent);
}
comparator.setComponentOrientation(root.getComponentOrientation());
return layoutPolicy.getComponentAfter(root, aComponent);
}
return null;
}
示例8: getComponentBefore
import java.awt.Container; //导入方法依赖的package包/类
/**
* Returns the component before.
* @return the component before
* @param aContainer a container
* @param aComponent a component
*/
public Component getComponentBefore(Container aContainer,
Component aComponent)
{
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.getComponentBefore(root, aComponent);
}
comparator.setComponentOrientation(root.getComponentOrientation());
return layoutPolicy.getComponentBefore(root, aComponent);
}
return null;
}
示例9: getFirstComponent
import java.awt.Container; //导入方法依赖的package包/类
/**
* Returns the first component.
* @return the first component
* @param aContainer a container
*/
public Component getFirstComponent(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.getFirstComponent(root);
}
comparator.setComponentOrientation(root.getComponentOrientation());
return layoutPolicy.getFirstComponent(root);
}
return null;
}
示例10: getLastComponent
import java.awt.Container; //导入方法依赖的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;
}
示例11: actionPerformed
import java.awt.Container; //导入方法依赖的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);
}
}