KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sample > amazon > amazonSimpleQueueService > ListenersOut


1 /*
2 * Copyright 2004,2005 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */

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 /**
26  * This will create the OMElement needed to be used in invokeNonBlocking() method
27  *
28  * @author Saminda Abeyruwan <saminda@opensource.lk>
29  */

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 JavaDoc runableCodeListMyQueues;
38     Runnable JavaDoc 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 JavaDoc thread = new Thread JavaDoc(this.runableCodeListMyQueues);
57             thread.start();
58         }
59     }
60
61     public void keyReleased(KeyEvent e) {
62         //To change body of implemented methods use File | Settings | File Templates.
63
}
64
65     public void keyTyped(KeyEvent e) {
66         //To change body of implemented methods use File | Settings | File Templates.
67
}
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 JavaDoc thread1 = new Thread JavaDoc(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 JavaDoc thread2 = new Thread JavaDoc(this.runnableCodeDequeue);
83             thread2.start();
84         }
85     }
86
87     public void mouseDragged(MouseEvent e) {
88         String JavaDoc selectedText = this.result.getSelectedText();
89         this.createQueue.setText(selectedText);
90     }
91
92     public void mouseMoved(MouseEvent e) {
93         //To change body of implemented methods use File | Settings | File Templates.
94
}
95 }
96
Popular Tags