Example usage for javax.swing JComponent hasFocus

List of usage examples for javax.swing JComponent hasFocus

Introduction

In this page you can find the example usage for javax.swing JComponent hasFocus.

Prototype

public boolean hasFocus() 

Source Link

Document

Returns true if this Component is the focus owner.

Usage

From source file:Main.java

/**
 * Request focus on the given component if it doesn't already have it
 * and <code>isRequestFocusEnabled()</code> returns true.
 *//*from  w  w w . jav  a  2  s  . co m*/
public static void adjustFocus(JComponent c) {
    if (!c.hasFocus() && c.isRequestFocusEnabled()) {
        c.requestFocus();
    }
}

From source file:org.nuclos.client.ui.collect.component.AbstractCollectableComponent.java

private boolean hasFocus() {
    // if the component has focus, other code far, far away sets the nice yellow
    // background which we don't want to overwride here ...
    JComponent focusComponent = getControlComponent();

    if (getJComponent() instanceof LabeledComboBox) {
        JComboBox cb = ((LabeledComboBox) getJComponent()).getJComboBox();
        focusComponent = (JComponent) (cb.getEditor() != null ? cb.getEditor().getEditorComponent() : cb);
    }/*from  ww w  .ja  v a 2 s  .  com*/

    return focusComponent.hasFocus();
}