Here you can find the source of addListenerToCommitOnFocusLost(final JTextField field)
Parameter | Description |
---|---|
field | field to commit when losing focus |
public static void addListenerToCommitOnFocusLost(final JTextField field)
//package com.java2s; //License from project: Open Source License import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import javax.swing.JTextField; public class Main { /**/* w w w . j a v a2s.c om*/ * Add Focus listener to text field to commit field whenever it loses focus. * @param field field to commit when losing focus */ public static void addListenerToCommitOnFocusLost(final JTextField field) { field.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { field.postActionEvent(); } }); } }