1 16 17 package de.schlichtherle.key.passwd.swing; 18 19 import de.schlichtherle.key.KeyProvider; 20 21 import java.awt.event.ActionEvent ; 22 import java.awt.event.ActionListener ; 23 24 import javax.swing.JButton ; 25 import javax.swing.JPanel ; 26 import javax.swing.JRootPane ; 27 import javax.swing.Timer ; 28 29 52 public abstract class BasicInvalidKeyFeedback extends BasicFeedback { 53 54 private int delay = KeyProvider.MIN_KEY_RETRY_DELAY; 55 56 62 public int getDelay() { 63 return delay; 64 } 65 66 71 public void setDelay(final int delay) { 72 this.delay = delay; 73 } 74 75 protected void startAnimation() { 76 startAnimation(getPanel(), getDelay()); 77 } 78 79 static void startAnimation(final JPanel panel, final int delay) { 80 final JRootPane rp = panel.getRootPane(); 81 final JButton b = rp.getDefaultButton(); 82 if (b == null) 83 return; 84 85 b.setEnabled(false); 86 87 final Timer t = new Timer (delay, new ActionListener () { 88 public void actionPerformed(ActionEvent e) { 89 b.setEnabled(true); 90 } 91 }); 92 t.setRepeats(false); 93 t.start(); 94 } 95 } 96 | Popular Tags |