public EMonitoredTextField(int columns) {
    super(null, null, columns);
    getDocument()
        .addDocumentListener(
            new DocumentListener() {
              public void changedUpdate(DocumentEvent e) {
                textChanged();
              }

              public void insertUpdate(DocumentEvent e) {
                textChanged();
              }

              public void removeUpdate(DocumentEvent e) {
                textChanged();
              }
            });
    timer =
        new Timer(
            500,
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                timerExpired();
              }
            });
    timer.setRepeats(false);
  }
Exemple #2
0
 static {
   caretTimer = new Timer(500, new CaretBlinker());
   caretTimer.setInitialDelay(500);
   caretTimer.start();
 }
 /** Restarts the timer every time the text changes. */
 public void textChanged() {
   timer.restart();
 }