Java Code Examples for java.awt.FocusTraversalPolicy#getFirstComponent()

The following examples show how to use java.awt.FocusTraversalPolicy#getFirstComponent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultFocusManager.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: DefaultFocusManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: DefaultFocusManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: DefaultFocusManager.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: DefaultFocusManager.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 6
Source File: DefaultFocusManager.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 7
Source File: DefaultFocusManager.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 8
Source File: DefaultFocusManager.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 9
Source File: DefaultFocusManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 10
Source File: DefaultFocusManager.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 11
Source File: DefaultFocusManager.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 12
Source File: DefaultFocusManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 13
Source File: DefaultFocusManager.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 14
Source File: DefaultFocusManager.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
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;
}
 
Example 15
Source File: DefaultFocusManager.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 16
Source File: DefaultFocusManager.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 17
Source File: DefaultFocusManager.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 18
Source File: ETable.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@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);
    }
}
 
Example 19
Source File: FormFocusTransversalPolicy.java    From jdal with Apache License 2.0 4 votes vote down vote up
@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);
}