1 16 package sample.amazon.amazonSimpleQueueService; 17 18 import sample.amazon.amazonSimpleQueueService.util.RunnableDeleteQueue; 19 import sample.amazon.amazonSimpleQueueService.util.RunnableListMyQueues; 20 import sample.amazon.amazonSimpleQueueService.util.RunnableReadQueue; 21 22 import javax.swing.*; 23 import java.awt.event.*; 24 25 30 public class ListenersOut implements KeyListener, ActionListener, MouseMotionListener { 31 JTextField createQueue; 32 JTextArea result; 33 JTextField queueCode; 34 JTextField read; 35 JButton buttonLoad; 36 JButton buttonDelete; 37 Runnable runableCodeListMyQueues; 38 Runnable runnableCodeDequeue; 39 40 public ListenersOut(JTextField createQueue, JTextField queueCode, JTextField read, 41 JTextArea result, JButton buttonLoad, JButton buttonDelete) { 42 this.queueCode = queueCode; 43 this.createQueue = createQueue; 44 this.read = read; 45 this.result = result; 46 this.buttonLoad = buttonLoad; 47 this.buttonDelete = buttonDelete; 48 } 49 50 public void keyPressed(KeyEvent e) { 51 if (e.getKeyCode() == KeyEvent.VK_ENTER) { 52 this.result.setText(""); 53 this.createQueue.setEditable(false); 54 this.runableCodeListMyQueues = new RunnableReadQueue(this.createQueue, 55 this.queueCode, this.read, this.result); 56 Thread thread = new Thread (this.runableCodeListMyQueues); 57 thread.start(); 58 } 59 } 60 61 public void keyReleased(KeyEvent e) { 62 } 64 65 public void keyTyped(KeyEvent e) { 66 } 68 69 public void actionPerformed(ActionEvent e) { 70 if (e.getActionCommand().equals("1")) { 71 this.runableCodeListMyQueues = new RunnableListMyQueues(this.createQueue, this.queueCode, this.read, 72 this.result, this.buttonLoad); 73 Thread thread1 = new Thread (this.runableCodeListMyQueues); 74 thread1.start(); 75 this.createQueue.setEditable(true); 76 this.buttonLoad.setText("Running.."); 77 } 78 if (e.getActionCommand().equals("2")) { 79 this.buttonDelete.setText("Running"); 80 this.runnableCodeDequeue = new RunnableDeleteQueue(this.createQueue, this.queueCode, this.read, 81 this.result, this.buttonDelete); 82 Thread thread2 = new Thread (this.runnableCodeDequeue); 83 thread2.start(); 84 } 85 } 86 87 public void mouseDragged(MouseEvent e) { 88 String selectedText = this.result.getSelectedText(); 89 this.createQueue.setText(selectedText); 90 } 91 92 public void mouseMoved(MouseEvent e) { 93 } 95 } 96 | Popular Tags |