Example usage for java.awt.event FocusListener focusGained

List of usage examples for java.awt.event FocusListener focusGained

Introduction

In this page you can find the example usage for java.awt.event FocusListener focusGained.

Prototype

public void focusGained(FocusEvent e);

Source Link

Document

Invoked when a component gains the keyboard focus.

Usage

From source file:com.github.fritaly.dualcommander.TabbedPane.java

@Override
public void focusGained(FocusEvent e) {
    // Propagate the event
    final FocusListener[] listeners = getListeners(FocusListener.class);

    if (listeners != null) {
        final FocusEvent event = new FocusEvent(this, e.getID(), e.isTemporary(), e.getOppositeComponent());

        for (FocusListener listener : listeners) {
            listener.focusGained(event);
        }/*  w  w w .j a v a  2  s.c o  m*/
    }
}

From source file:com.github.fritaly.dualcommander.DirectoryBrowser.java

@Override
public void focusGained(FocusEvent e) {
    if (e.getSource() == table) {
        // Propagate the event
        final FocusListener[] listeners = getListeners(FocusListener.class);

        if (listeners != null) {
            final FocusEvent event = new FocusEvent(this, e.getID(), e.isTemporary(), e.getOppositeComponent());

            for (FocusListener listener : listeners) {
                listener.focusGained(event);
            }//from  www. jav  a  2s  .c  om
        }
    }
}

From source file:edu.ku.brc.af.ui.forms.validation.ValComboBoxFromQuery.java

/**
 * Constructor./*from   w  ww  .java  2  s . com*/
 * @param tableInfo
 * @param keyFieldName
 * @param displayColumn
 * @param keyName
 * @param format
 * @param uiFieldFormatterName
 * @param dataObjFormatterName
 * @param sqlTemplate
 * @param helpContext
 * @param btns
 */
public ValComboBoxFromQuery(final DBTableInfo tableInfo, final String keyFieldName, final String displayColumn,
        final String keyName, final String format, final String uiFieldFormatterName,
        final String dataObjFormatterName, final String sqlTemplate, final String helpContext, final int btns)

{
    if (StringUtils.isEmpty(displayColumn)) {
        FormDevHelper.showFormDevError(
                "For ValComboBoxFromQuery table[" + tableInfo.getName() + "] displayColumn null.");
        return;
    }
    if (StringUtils.isEmpty(format) && StringUtils.isEmpty(uiFieldFormatterName)) {
        FormDevHelper.showFormDevError("For ValComboBoxFromQuery table[" + tableInfo.getName()
                + "] both format and fieldFormatterName are null.");
        return;
    }
    if (StringUtils.isEmpty(tableInfo.getNewObjDialog())) {
        FormDevHelper.showFormDevError("For ValComboBoxFromQuery table[" + tableInfo.getName()
                + "]  New Obj Dialog name (displayInfoDialogName) is null.");
        return;
    }

    this.tableInfo = tableInfo;
    this.keyName = keyName;
    this.dataObjFormatterName = dataObjFormatterName != null ? dataObjFormatterName
            : tableInfo.getDataObjFormatter();
    this.frameTitle = tableInfo.getTitle();
    this.helpContext = helpContext;

    textWithQuery = new TextFieldWithQuery(tableInfo, keyFieldName, displayColumn, format, uiFieldFormatterName,
            sqlTemplate);
    restrictedStr = FormHelper.checkForRestrictedValue(tableInfo);
    if (restrictedStr != null) {
        isRestricted = true;
        textWithQuery.setEnabled(false);

    } else {

        textWithQuery.addListSelectionListener(this);
        textWithQuery.setAddAddItem(true);

        textWithQuery.getTextField().addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                //log.debug("focusGained");
                hasFocus = true;
                super.focusGained(e);
                validateState();
                repaint();

                for (FocusListener l : focusListeners) {
                    l.focusGained(e);
                }
            }

            @Override
            public void focusLost(FocusEvent e) {
                //log.debug("focusLost");
                hasFocus = false;
                super.focusLost(e);

                validateState();
                repaint();

                for (FocusListener l : focusListeners) {
                    l.focusLost(e);
                }

                if (!textWithQuery.isPopupShowing()) {
                    refreshUIFromData(true);
                }
            }
        });
    }

    init(tableInfo.getTitle(), btns);

    setOpaque(false);
}