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


Java FocusTraversalPolicy.getComponentAfter方法代码示例

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


在下文中一共展示了FocusTraversalPolicy.getComponentAfter方法的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: 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

示例3: 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

示例4: 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

示例5: getFocusableComponents

import java.awt.FocusTraversalPolicy; //导入方法依赖的package包/类
/** Returns a set of all the components that
 * can have the keyboard focus.
 * <P>My first implementation involved of this concept
 * simply involved asking JCompnonents if they were
 * focusable, but in the <code>FilledButtonTest</code> this
 * resulted in shifting focus to the ContentPane.  Although
 * it is technically focusable: if I used the tab key
 * I did <i>not</i> get this result.  So I studied
 * the inner workings for Component.transferFocus()
 * and ended up with a method that involved
 * calls to <code>getFocusCycleRootAncestor()</code>,
 * and <code>getFocusTraversalPolicy()</code>.
 * <P>(Also credit goes to Werner for originally tipping me off
 * towards looking at FocusTraversalPolicies.)
 * @param currentFocusOwner the current focus owner.
 * @return all the JComponents that can receive the focus.
 */
public static Set<Component> getFocusableComponents(Component currentFocusOwner) {
	HashSet<Component> set = new HashSet<Component>();
	set.add(currentFocusOwner);

       Container rootAncestor = currentFocusOwner.getFocusCycleRootAncestor();
       Component comp = currentFocusOwner;
       while (rootAncestor != null && 
              !(rootAncestor.isShowing() && 
                rootAncestor.isFocusable() && 
                rootAncestor.isEnabled())) 
       {
           comp = rootAncestor;
           rootAncestor = comp.getFocusCycleRootAncestor();
       }
       if (rootAncestor != null) {
           FocusTraversalPolicy policy =
               rootAncestor.getFocusTraversalPolicy();
           Component toFocus = policy.getComponentAfter(rootAncestor, comp);
           
           while(toFocus!=null && set.contains(toFocus)==false) {
           	set.add(toFocus);
               toFocus = policy.getComponentAfter(rootAncestor, toFocus);
           }
           
           toFocus = policy.getComponentBefore(rootAncestor, comp);
           
           while(toFocus!=null && set.contains(toFocus)==false) {
           	set.add(toFocus);
               toFocus = policy.getComponentBefore(rootAncestor, toFocus);
           }
       }
	return set;
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:51,代码来源:FocusArrowListener.java

示例6: getNextFocusableComponent

import java.awt.FocusTraversalPolicy; //导入方法依赖的package包/类
/**
 * Return the value of the <code>nextFocusableComponent</code> property.
 *
 * @return The current value of the property, or <code>null</code>
 * if none has been set.
 *
 * @deprecated See {@link java.awt.FocusTraversalPolicy}
 */
public Component getNextFocusableComponent()
{
  Container focusRoot = this;
  if (! this.isFocusCycleRoot())
    focusRoot = getFocusCycleRootAncestor();

  FocusTraversalPolicy policy  = focusRoot.getFocusTraversalPolicy();
  return policy.getComponentAfter(focusRoot, this);
}
 
开发者ID:vilie,项目名称:javify,代码行数:18,代码来源:JComponent.java

示例7: onTakeFocus

import java.awt.FocusTraversalPolicy; //导入方法依赖的package包/类
@Override
public void onTakeFocus(CefBrowser browser, boolean next) {
  if (browser == null)
    return;

  browser.setFocus(false);
  Container parent = browser.getUIComponent().getParent();
  if (parent != null) {
    FocusTraversalPolicy policy = null;
    while (parent != null) {
      policy = parent.getFocusTraversalPolicy();
      if (policy != null)
        break;
      parent = parent.getParent();
    }
    if (policy != null) {
      Component nextComp = next ? policy.getComponentAfter(parent, browser.getUIComponent())
                                : policy.getComponentBefore(parent, browser.getUIComponent());
      if (nextComp == null) {
        policy.getDefaultComponent(parent).requestFocus();
      } else {
        nextComp.requestFocus();
      }
    }
  }
  focusedBrowser_ = null;
  if (focusHandler_ != null)
    focusHandler_.onTakeFocus(browser, next);
}
 
开发者ID:viglucci,项目名称:app-jcef-example,代码行数:30,代码来源:CefClient.java

示例8: getNextFocusableComponent

import java.awt.FocusTraversalPolicy; //导入方法依赖的package包/类
/**
 * Return the value of the <code>nextFocusableComponent</code> property.
 *
 * @return The current value of the property, or <code>null</code>
 * if none has been set.
 * 
 * @deprecated See {@link java.awt.FocusTraversalPolicy}
 */
public Component getNextFocusableComponent()
{
  Container focusRoot = this;
  if (! this.isFocusCycleRoot())
    focusRoot = getFocusCycleRootAncestor();

  FocusTraversalPolicy policy  = focusRoot.getFocusTraversalPolicy();
  return policy.getComponentAfter(focusRoot, this);
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:18,代码来源:JComponent.java

示例9: getFocusableComponents

import java.awt.FocusTraversalPolicy; //导入方法依赖的package包/类
/** Returns a set of all the components that
	 * can have the keyboard focus.
	 * <P>My first implementation involved of this concept
	 * simply involved asking JCompnonents if they were
	 * focusable, but in the <code>FilledButtonTest</code> this
	 * resulted in shifting focus to the ContentPane.  Although
	 * it is technically focusable: if I used the tab key
	 * I did <i>not</i> get this result.  So I studied
	 * the inner workings for Component.transferFocus()
	 * and ended up with a method that involved
	 * calls to <code>getFocusCycleRootAncestor()</code>,
	 * and <code>getFocusTraversalPolicy()</code>.
	 * <P>(Also credit goes to Werner for originally tipping me off
	 * towards looking at FocusTraversalPolicies.)
	 * @param currentFocusOwner the current focus owner.
	 * @return all the JComponents that can receive the focus.
	 */
	public static Set<Component> getFocusableComponents(Component currentFocusOwner) {
		HashSet<Component> set = new HashSet<Component>();
		set.add(currentFocusOwner);

        Container rootAncestor = currentFocusOwner.getFocusCycleRootAncestor();
        Component comp = currentFocusOwner;
        while (rootAncestor != null && 
               !(rootAncestor.isShowing() && 
                 rootAncestor.isFocusable() && 
                 rootAncestor.isEnabled())) 
        {
            comp = rootAncestor;
            rootAncestor = comp.getFocusCycleRootAncestor();
        }
        if (rootAncestor != null) {
            FocusTraversalPolicy policy =
                rootAncestor.getFocusTraversalPolicy();
            Component toFocus = policy.getComponentAfter(rootAncestor, comp);
//            final Component startingPoint = currentFocusOwner;
            
            while(toFocus!=null && set.contains(toFocus)==false) {
            	set.add(toFocus);
                toFocus = policy.getComponentAfter(rootAncestor, toFocus);
            }
            
            toFocus = policy.getComponentBefore(rootAncestor, comp);
            
            while(toFocus!=null && set.contains(toFocus)==false) {
            	set.add(toFocus);
                toFocus = policy.getComponentBefore(rootAncestor, toFocus);
            }
        }
		return set;
	}
 
开发者ID:phylogeography,项目名称:SpreaD3,代码行数:52,代码来源:FocusArrowListener.java

示例10: onTakeFocus

import java.awt.FocusTraversalPolicy; //导入方法依赖的package包/类
@Override
public void onTakeFocus(CefBrowser browser, boolean next) {
	if (browser == null) 
		return;
	
	browser.setFocus(false);
	Container parent = browser.getUIComponent().getParent();
	if (parent != null) {
		FocusTraversalPolicy policy = null;
		while (parent != null) {
			policy = parent.getFocusTraversalPolicy();
			if (policy != null)
				break;
			parent = parent.getParent();
		}
		if (policy != null) {
			Component nextComp = next ? policy.getComponentAfter(parent, browser.getUIComponent()) 
                                               : policy.getComponentBefore(parent, browser.getUIComponent());
			if (nextComp == null) {
				policy.getDefaultComponent(parent).requestFocus();
			} else {
				nextComp.requestFocus();
			}
		}
	}
	if (focusHandler_ != null)
		focusHandler_.onTakeFocus(browser, next);
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:29,代码来源:CefClient.java

示例11: actionPerformed

import java.awt.FocusTraversalPolicy; //导入方法依赖的package包/类
public void actionPerformed(final ActionEvent e) {
    Container ancestor = desktop.getFocusCycleRootAncestor();
    if (ancestor == null) {
        return;
    }

    FocusTraversalPolicy policy = ancestor.getFocusTraversalPolicy();
    if (!(policy instanceof SortingFocusTraversalPolicy)) {
        return;
    }

    SortingFocusTraversalPolicy sortingPolicy = (SortingFocusTraversalPolicy)policy;

    boolean implicitEnabled = sortingPolicy.getImplicitDownCycleTraversal();
    sortingPolicy.setImplicitDownCycleTraversal(false);

    Component result = null;
    String action = (String)getValue(NAME);
    if ("navigateNext".equals(action)) {
        result = policy.getComponentAfter(ancestor, desktop);
    } else if ("navigatePrevious".equals(action)) {
        result = policy.getComponentBefore(ancestor, desktop);
    }

    sortingPolicy.setImplicitDownCycleTraversal(implicitEnabled);

    if (result != null) {
        result.requestFocus();
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:31,代码来源:BasicDesktopPaneUI.java

示例12: actionPerformed

import java.awt.FocusTraversalPolicy; //导入方法依赖的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

示例13: getComponentAfter

import java.awt.FocusTraversalPolicy; //导入方法依赖的package包/类
@Override
public Component getComponentAfter(Container container,
		Component component) {
	
	// Fix awt bug looking for ComboBoxEditor instead ComboBox
	// see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6205817
	if (component.getParent() instanceof JComboBox)
			component = component.getParent();

	int index = components.indexOf(component);
	
	if (index == -1) { // not owner
		Container childContainer =  getTopmostProvider(container, component);
		if (childContainer == null)
			return getFirstComponent(container);
		
		FocusTraversalPolicy ftp = childContainer.getFocusTraversalPolicy();
		if (ftp != null && ftp != this) {
			Component next =  ftp.getComponentAfter(childContainer, component);
			if (next != ftp.getFirstComponent(container)) 
				return next;
			
			// child cycle
			do {
				index = components.indexOf(childContainer);
				childContainer = childContainer.getParent();
			} while (index == -1 || childContainer == null);
			
			if (index == -1) {
				log.warn("I can't figure what is the next component");
				return getFirstComponent(container);
			}
		}
	}
	
	index++;
	
	if (index < components.size() && index >= 0) {
		Component c = getComponent(index);
		if (c.isEnabled() && c.isFocusable()) 
			return c;
		else 
			return getComponentAfter(container, c);
	}
	
	return getFirstComponent(container);
}
 
开发者ID:chelu,项目名称:jdal,代码行数:48,代码来源:FormFocusTransversalPolicy.java


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