import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
++import java.awt.event.FocusEvent;
++import java.awt.event.FocusListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
++import javax.swing.Timer;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
}
});
-- txt_search.getDocument().addDocumentListener(new DocumentListener()
++ final DeferredTextInputListener listener = new DeferredTextInputListener(
++ 500,
++ new ActionListener()
++ {
++ @Override
++ public void actionPerformed(ActionEvent e)
++ {
++ searchAction();
++ }
++ }, false);
++ txt_search.getDocument().addDocumentListener(listener);
++ txt_search.addFocusListener(new FocusListener()
{
@Override
-- public void insertUpdate(DocumentEvent e)
++ public void focusGained(FocusEvent e)
{
- searchAction();
- }
-
- @Override
- public void removeUpdate(DocumentEvent e)
- {
- searchAction();
- txt_search_ActionPerformed();
++ listener.start();
}
@Override
- public void changedUpdate(DocumentEvent e)
- public void removeUpdate(DocumentEvent e)
++ public void focusLost(FocusEvent e)
{
- searchAction();
- txt_search_ActionPerformed();
- }
-
- @Override
- public void changedUpdate(DocumentEvent e)
- {
- txt_search_ActionPerformed();
++ listener.stop();
}
});
mainFrame.setVisible(true);
mainFrame.setContentPane(this);
mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- Desktop.addInternalFrame(mainFrame, frameTitle, 800, 400);
+ Desktop.addInternalFrame(mainFrame, getFTSFrameTitle(), 800, 400);
+ }
+
++ public class DeferredTextInputListener implements DocumentListener
++ {
++ private final Timer swingTimer;
++
++ public DeferredTextInputListener(int timeOut, ActionListener listener,
++ boolean repeats)
++ {
++ swingTimer = new Timer(timeOut, listener);
++ swingTimer.setRepeats(repeats);
++ }
++
++ public void start()
++ {
++ swingTimer.start();
++ }
++
++ public void stop()
++ {
++ swingTimer.stop();
++ }
++
++ @Override
++ public void insertUpdate(DocumentEvent e)
++ {
++ swingTimer.restart();
++ }
++
++ @Override
++ public void removeUpdate(DocumentEvent e)
++ {
++ swingTimer.restart();
++ }
++
++ @Override
++ public void changedUpdate(DocumentEvent e)
++ {
++ swingTimer.restart();
++ }
++
+ }
+
public boolean wantedFieldsUpdated()
{
if (previousWantedFields == null)