Example usage for java.awt.event FocusListener focusLost

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

Introduction

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

Prototype

public void focusLost(FocusEvent e);

Source Link

Document

Invoked when a component loses the keyboard focus.

Usage

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

@Override
public void focusLost(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.focusLost(event);
        }/* w ww .  ja  va  2  s  .co  m*/
    }
}

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

@Override
public void focusLost(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.focusLost(event);
            }//from  w ww . j ava 2  s  . c  o m
        }
    }
}

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

/**
 * Constructor.//  w w w . j  a v  a2 s  .co  m
 * @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);
}