javax.swing.JRootPane#setDefaultButton ( )源码实例Demo

下面列出了javax.swing.JRootPane#setDefaultButton ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: stendhal   文件: StyledButtonUI.java
/**
 * Change the default button of the root pane of the specified
 * component.
 *
 * @param component the component whose root pane's default button
 *	should be changed. It must be a JButton.
 * @param setDefault if <code>true</code>, set the JButton specified by
 * 	<code>component</code> as the default. Otherwise the default button
 * 	is set to none
 */
private void changeDefault(Component component, boolean setDefault) {
	if (component instanceof JButton) {
		JButton button = (JButton) component;
		JRootPane parent = button.getRootPane();
		/*
		 * In some conditions, when pushing the button results
		 * in it being removed from the root container, a focus
		 * event can be processed after the button (or its parents)
		 * has been removed, so we need to check for a non-null
		 * root for a focused button, even though that seems
		 * nonsensical.
		 */
		if (parent != null) {
			if (setDefault) {
				parent.setDefaultButton(button);
			} else {
				parent.setDefaultButton(null);
			}
		}
	}
}
 
源代码2 项目: freecol   文件: FreeColOptionPaneUI.java
/**
 * {@inheritDoc}
 */
@Override
public void selectInitialValue(JOptionPane op) {
    if (initialFocusComponent != null) {
        initialFocusComponent.requestFocus();
 
        if (initialFocusComponent instanceof JButton) {
            JRootPane root = SwingUtilities.getRootPane(initialFocusComponent);
            if (root != null) {
                root.setDefaultButton((JButton)initialFocusComponent);
            }
        }
    }
}
 
源代码3 项目: Logisim   文件: DefaultRegistry.java
public DefaultRegistry(JRootPane rootPane) {
	this.rootPane = rootPane;
	rootPane.setDefaultButton(null);
}