Changeset 2947 in osm for applications/editors/josm/plugins/surveyor/src/test
- Timestamp:
- 2007-05-19T23:50:23+02:00 (18 years ago)
- Location:
- applications/editors/josm/plugins/surveyor/src/test
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/surveyor/src/test/DialogClosingThread.java
r2936 r2947 2 2 * 3 3 */ 4 package at.dallermassl.josm.plugin.surveyor.action;4 package test; 5 5 6 import java.awt.Component; 7 import java.awt.Container; 8 import java.awt.event.KeyEvent; 9 import java.awt.event.KeyListener; 10 11 import javax.swing.JButton; 6 12 import javax.swing.JDialog; 13 import javax.swing.JOptionPane; 14 import javax.swing.JPanel; 15 import javax.swing.JTextField; 16 import javax.swing.event.DocumentEvent; 17 import javax.swing.event.DocumentListener; 7 18 8 19 /** … … 10 21 * 11 22 */ 12 public class DialogClosingThread extends Thread {23 public class DialogClosingThread extends Thread implements KeyListener, DocumentListener { 13 24 private static long DEFAULT_TIMEOUT = 5000; 14 25 private JDialog dialog; … … 49 60 } catch(InterruptedException ignore) {} 50 61 } 62 51 63 dialog.setVisible(false); 52 64 dialog.dispose(); 53 65 } 66 67 public void reset() { 68 this.loopCount = timeout / 1000; 69 } 70 71 /* (non-Javadoc) 72 * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent) 73 */ 74 @Override 75 public void keyPressed(KeyEvent e) { 76 reset(); 77 System.out.println("keypressed: " + e.getKeyCode()); 78 } 79 80 /* (non-Javadoc) 81 * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent) 82 */ 83 @Override 84 public void keyReleased(KeyEvent e) { 85 reset(); 86 System.out.println("keyreleased: " + e.getKeyCode()); 87 } 88 89 /* (non-Javadoc) 90 * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent) 91 */ 92 @Override 93 public void keyTyped(KeyEvent e) { 94 reset(); 95 System.out.println("keytyped: " + e.getKeyCode()); 96 } 97 98 /** 99 * @param optionPane 100 */ 101 public void observe(Container container) { 102 for(Component component : container.getComponents()) { 103 if(component instanceof JTextField) { 104 observe((JTextField)component); 105 } else { 106 observe(component); 107 } 108 } 109 } 110 111 public void observe(Component component) { 112 component.addKeyListener(this); 113 } 114 115 public void observe(JTextField textfield) { 116 textfield.getDocument().addDocumentListener(this); 117 } 118 119 /* (non-Javadoc) 120 * @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent) 121 */ 122 @Override 123 public void changedUpdate(DocumentEvent e) { 124 reset(); 125 System.out.println("changedUpdate: " + e); 126 } 127 128 /* (non-Javadoc) 129 * @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent) 130 */ 131 @Override 132 public void insertUpdate(DocumentEvent e) { 133 reset(); 134 System.out.println("insertUpdate: " + e); 135 } 136 137 /* (non-Javadoc) 138 * @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent) 139 */ 140 @Override 141 public void removeUpdate(DocumentEvent e) { 142 reset(); 143 System.out.println("removeUpdate: " + e); 144 } 54 145 }
Note:
See TracChangeset
for help on using the changeset viewer.