当前位置: 首页>>代码示例>>Java>>正文


Java FocusTraversalPolicy类代码示例

本文整理汇总了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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:CategoryList.java

示例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();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:NodeOperationImpl.java

示例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();
			}
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:28,代码来源:FlatterSpinnerUI.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:DefaultFocusManager.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:DefaultFocusManager.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:DefaultFocusManager.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:DefaultFocusManager.java

示例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");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:InitialFTP.java

示例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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:LegacyGlueFocusTraversalPolicy.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:DefaultFocusManager.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:DefaultFocusManager.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:DefaultFocusManager.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:DefaultFocusManager.java


注:本文中的java.awt.FocusTraversalPolicy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。