當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。