本文整理汇总了Java中java.awt.FocusTraversalPolicy类的典型用法代码示例。如果您正苦于以下问题:Java FocusTraversalPolicy类的具体用法?Java FocusTraversalPolicy怎么用?Java FocusTraversalPolicy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FocusTraversalPolicy类属于java.awt包,在下文中一共展示了FocusTraversalPolicy类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import java.awt.FocusTraversalPolicy; //导入依赖的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: showProperties
import java.awt.FocusTraversalPolicy; //导入依赖的package包/类
/** Opens a modal propertySheet on given Node
* @param n the node to show properties for
*/
public void showProperties (Node n) {
Dialog d = findCachedPropertiesDialog( n );
if( null == d ) {
Node[] nds = new Node[] { n };
openProperties(new NbSheet(), nds);
} else {
d.setVisible( true );
//#131724 - PropertySheet clears its Nodes in removeNotify and keeps
//only a weakref which is being reused in subsequent addNotify
//so we should set the Nodes again in case the weakref got garbage collected
//pls note that PropertySheet code checks for redundant calls of setNodes
NbSheet sheet = findCachedSheet( d );
if( null != sheet )
sheet.setNodes(new Node[] { n });
d.toFront();
FocusTraversalPolicy ftp = d.getFocusTraversalPolicy();
if( null != ftp && null != ftp.getDefaultComponent(d) ) {
ftp.getDefaultComponent(d).requestFocusInWindow();
} else {
d.requestFocusInWindow();
}
}
}
示例3: focusSpinnerIfNecessary
import java.awt.FocusTraversalPolicy; //导入依赖的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();
}
}
}
}
示例4: getComponentAfter
import java.awt.FocusTraversalPolicy; //导入依赖的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;
}
示例5: getComponentBefore
import java.awt.FocusTraversalPolicy; //导入依赖的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;
}
示例6: getFirstComponent
import java.awt.FocusTraversalPolicy; //导入依赖的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;
}
示例7: 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;
}
示例8: test
import java.awt.FocusTraversalPolicy; //导入依赖的package包/类
public static void test(Window win, Class<? extends FocusTraversalPolicy> expectedPolicy) {
FocusTraversalPolicy ftp = win.getFocusTraversalPolicy();
System.out.println("==============" + "\n" +
"Tested window: " + win + "\n" +
"Expected policy: " + expectedPolicy + "\n" +
"Effective policy: " + ftp.getClass());
if (!expectedPolicy.equals(ftp.getClass())) {
throw new RuntimeException("Test failed: wrong effective focus policy");
}
}
示例9: readObject
import java.awt.FocusTraversalPolicy; //导入依赖的package包/类
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
ObjectInputStream.GetField f = in.readFields();
@SuppressWarnings("unchecked")
HashMap<Component, Component> newForwardMap =
(HashMap<Component, Component> ) f.get("forwardMap", null);
if (newForwardMap == null) {
throw new InvalidObjectException("Null forwardMap");
}
forwardMap = newForwardMap;
@SuppressWarnings("unchecked")
HashMap<Component, Component> newBackwardMap =
(HashMap<Component, Component>) f.get("backwardMap", null);
if (newBackwardMap == null) {
throw new InvalidObjectException("Null backwardMap");
}
backwardMap = newBackwardMap;
delegatePolicy = (FocusTraversalPolicy)in.readObject();
delegateManager = (DefaultFocusManager)in.readObject();
}
示例10: getComponentAfter
import java.awt.FocusTraversalPolicy; //导入依赖的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;
}
示例11: getComponentBefore
import java.awt.FocusTraversalPolicy; //导入依赖的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;
}
示例12: getFirstComponent
import java.awt.FocusTraversalPolicy; //导入依赖的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;
}
示例13: 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;
}