當前位置: 首頁>>代碼示例>>Java>>正文


Java FocusTraversalPolicy.getFirstComponent方法代碼示例

本文整理匯總了Java中java.awt.FocusTraversalPolicy.getFirstComponent方法的典型用法代碼示例。如果您正苦於以下問題:Java FocusTraversalPolicy.getFirstComponent方法的具體用法?Java FocusTraversalPolicy.getFirstComponent怎麽用?Java FocusTraversalPolicy.getFirstComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.FocusTraversalPolicy的用法示例。


在下文中一共展示了FocusTraversalPolicy.getFirstComponent方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

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

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

示例3: focusFirstComponentNow

import java.awt.FocusTraversalPolicy; //導入方法依賴的package包/類
private static void focusFirstComponentNow(JComponent component) {
	FocusTraversalPolicy focusPolicy = component.getFocusTraversalPolicy();
	if (component instanceof JTextComponent || component instanceof JComboBox || component instanceof JCheckBox) {
		component.requestFocus();
	} else if (focusPolicy != null && focusPolicy.getFirstComponent(component) != null) {
		focusPolicy.getFirstComponent(component).requestFocus();
	} else {
		FocusManager.getCurrentManager().focusNextComponent(component);
	}
}
 
開發者ID:BrunoEberhard,項目名稱:minimal-j,代碼行數:11,代碼來源:SwingFrontend.java

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

示例5: 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.getFirstComponent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。