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


Java Container.getFocusCycleRootAncestor方法代码示例

本文整理汇总了Java中java.awt.Container.getFocusCycleRootAncestor方法的典型用法代码示例。如果您正苦于以下问题:Java Container.getFocusCycleRootAncestor方法的具体用法?Java Container.getFocusCycleRootAncestor怎么用?Java Container.getFocusCycleRootAncestor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Container的用法示例。


在下文中一共展示了Container.getFocusCycleRootAncestor方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

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

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

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

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

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

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

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

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

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

示例10: actionPerformed

import java.awt.Container; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
    int next = getSelectedRow() + (direction ? 1 : (-1));

    //if we're off the end, try to find a sibling component to pass
    //focus to
    if ((next >= getRowCount()) || (next < 0)) {
        if (!(BaseTable.this.getTopLevelAncestor() instanceof Dialog)) {
            //If we're not in a dialog, we're in the main window - don't
            //send focus somewhere because the winsys won't change the
            //active mode
            next = (next >= getRowCount()) ? 0 : (getRowCount() - 1);
        } else if ((next >= getRowCount()) || (next < 0)) {
            //if we're off the end, try to find a sibling component to pass
            //focus to
            //This code is a bit ugly, but works
            Container ancestor = getFocusCycleRootAncestor();

            //Find the next component in our parent's focus cycle
            Component sibling = direction
                ? ancestor.getFocusTraversalPolicy().getComponentAfter(ancestor, BaseTable.this.getParent())
                : ancestor.getFocusTraversalPolicy().getComponentBefore(ancestor, BaseTable.this);

            //Often LayoutFocusTranferPolicy will return ourselves if we're
            //the last.  First try to find a parent focus cycle root that
            //will be a little more polite
            if (sibling == BaseTable.this) {
                Container grandcestor = ancestor.getFocusCycleRootAncestor();

                if (grandcestor != null) {
                    sibling = direction
                        ? grandcestor.getFocusTraversalPolicy().getComponentAfter(grandcestor, ancestor)
                        : grandcestor.getFocusTraversalPolicy().getComponentBefore(grandcestor, ancestor);
                    ancestor = grandcestor;
                }
            }

            //Okay, we still ended up with ourselves, or there is only one focus
            //cycle root ancestor.  Try to find the first component according to
            //the policy
            if (sibling == BaseTable.this) {
                if (ancestor.getFocusTraversalPolicy().getFirstComponent(ancestor) != null) {
                    sibling = ancestor.getFocusTraversalPolicy().getFirstComponent(ancestor);
                }
            }

            //If we're *still* getting ourselves, find the default button and punt
            if (sibling == BaseTable.this) {
                JRootPane rp = getRootPane();
                JButton jb = rp.getDefaultButton();

                if (jb != null) {
                    sibling = jb;
                }
            }

            //See if it's us, or something we know about, and if so, just
            //loop around to the top or bottom row - there's noplace
            //interesting for focus to go to
            if (sibling != null) {
                if (sibling == BaseTable.this) {
                    //set the selection if there's nothing else to do
                    changeSelection(
                        direction ? 0 : (getRowCount() - 1), direction ? 0 : (getColumnCount() - 1), false,
                        false
                    );
                } else {
                    //Request focus on the sibling
                    sibling.requestFocus();
                }

                return;
            }
        }

        changeSelection(next, getSelectedColumn(), false, false);
    }

    if( getSelectionModel().getAnchorSelectionIndex() < 0 )
        getSelectionModel().setAnchorSelectionIndex(next);
    getSelectionModel().setLeadSelectionIndex(next);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:82,代码来源:BaseTable.java

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


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