2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2003, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: SetNumericDialog.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.4 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/02/23 20:59:59 $ |
2 |
26 Feb 07 |
jari |
* $Author: caliente $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
package org.tigr.microarray.util.awt; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.event.ItemEvent; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.event.ItemListener; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.event.KeyEvent; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.event.KeyListener; |
2 |
26 Feb 07 |
jari |
22 |
import java.util.Hashtable; |
2 |
26 Feb 07 |
jari |
23 |
import java.util.Vector; |
2 |
26 Feb 07 |
jari |
24 |
|
2 |
26 Feb 07 |
jari |
25 |
import javax.swing.JButton; |
2 |
26 Feb 07 |
jari |
26 |
import javax.swing.JComboBox; |
2 |
26 Feb 07 |
jari |
27 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
28 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
29 |
import javax.swing.JTextField; |
2 |
26 Feb 07 |
jari |
30 |
|
2 |
26 Feb 07 |
jari |
31 |
import org.tigr.util.awt.ActionInfoDialog; |
2 |
26 Feb 07 |
jari |
32 |
import org.tigr.util.awt.ActionInfoEvent; |
2 |
26 Feb 07 |
jari |
33 |
import org.tigr.util.awt.GBA; |
2 |
26 Feb 07 |
jari |
34 |
|
2 |
26 Feb 07 |
jari |
35 |
public class SetNumericDialog extends ActionInfoDialog { |
2 |
26 Feb 07 |
jari |
36 |
protected JFrame parent; |
2 |
26 Feb 07 |
jari |
37 |
JLabel numberLabel; |
2 |
26 Feb 07 |
jari |
38 |
JTextField numberTextField; |
2 |
26 Feb 07 |
jari |
39 |
JComboBox numberChoice; |
2 |
26 Feb 07 |
jari |
40 |
JButton cancelButton, okButton; |
2 |
26 Feb 07 |
jari |
41 |
GBA gba; |
2 |
26 Feb 07 |
jari |
42 |
|
2 |
26 Feb 07 |
jari |
43 |
public SetNumericDialog(JFrame parent, Vector numberListVector) { |
2 |
26 Feb 07 |
jari |
44 |
super(parent, false); |
2 |
26 Feb 07 |
jari |
45 |
try { |
2 |
26 Feb 07 |
jari |
46 |
this.parent = parent; |
2 |
26 Feb 07 |
jari |
47 |
gba = new GBA(); |
2 |
26 Feb 07 |
jari |
48 |
|
2 |
26 Feb 07 |
jari |
49 |
numberLabel = new JLabel("Analysis_id: "); |
2 |
26 Feb 07 |
jari |
50 |
numberLabel.addKeyListener(new EventListener()); |
2 |
26 Feb 07 |
jari |
51 |
|
2 |
26 Feb 07 |
jari |
52 |
numberTextField = new JTextField(15); |
2 |
26 Feb 07 |
jari |
53 |
numberTextField.addKeyListener(new EventListener()); |
2 |
26 Feb 07 |
jari |
54 |
|
2 |
26 Feb 07 |
jari |
55 |
numberChoice = new JComboBox(); |
2 |
26 Feb 07 |
jari |
56 |
numberChoice.addItemListener(new EventListener()); |
2 |
26 Feb 07 |
jari |
57 |
numberChoice.addKeyListener(new EventListener()); |
2 |
26 Feb 07 |
jari |
58 |
|
2 |
26 Feb 07 |
jari |
59 |
String[] numbers; |
2 |
26 Feb 07 |
jari |
60 |
for (int j = 1; j < numberListVector.size(); j++) { |
2 |
26 Feb 07 |
jari |
61 |
numbers = ((String[]) numberListVector.elementAt(j)); |
2 |
26 Feb 07 |
jari |
62 |
|
2 |
26 Feb 07 |
jari |
63 |
for (int i = 0; i < numbers.length; i++) { |
2 |
26 Feb 07 |
jari |
64 |
numberChoice.addItem(numbers[i]); |
2 |
26 Feb 07 |
jari |
65 |
} |
2 |
26 Feb 07 |
jari |
66 |
} |
2 |
26 Feb 07 |
jari |
67 |
|
2 |
26 Feb 07 |
jari |
68 |
cancelButton = new JButton("Cancel"); |
2 |
26 Feb 07 |
jari |
69 |
cancelButton.addActionListener(new EventListener()); |
2 |
26 Feb 07 |
jari |
70 |
|
2 |
26 Feb 07 |
jari |
71 |
okButton = new JButton("OK"); |
2 |
26 Feb 07 |
jari |
72 |
okButton.addActionListener(new EventListener()); |
2 |
26 Feb 07 |
jari |
73 |
|
2 |
26 Feb 07 |
jari |
74 |
contentPane.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
75 |
gba.add(contentPane, numberLabel, 0, 0, 1, 1, 0, 0, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
76 |
gba.add(contentPane, numberTextField, 1, 0, 1, 1, 1, 1, GBA.H, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
77 |
gba.add(contentPane, okButton, 2, 0, 1, 1, 0, 0, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
78 |
gba.add(contentPane, numberChoice, 1, 1, 1, 1, 1, 1, GBA.H, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
79 |
gba.add(contentPane, cancelButton, 2, 1, 1, 1, 0, 0, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
80 |
|
2 |
26 Feb 07 |
jari |
81 |
pack(); |
2 |
26 Feb 07 |
jari |
82 |
setResizable(false); |
2 |
26 Feb 07 |
jari |
83 |
setTitle("Select Analysis_ID"); |
2 |
26 Feb 07 |
jari |
84 |
numberTextField.grabFocus(); |
2 |
26 Feb 07 |
jari |
85 |
setLocation(250, 250); |
2 |
26 Feb 07 |
jari |
86 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
87 |
System.out.println("Exception (SetNumericDialog.const()): " + e); |
2 |
26 Feb 07 |
jari |
88 |
} |
2 |
26 Feb 07 |
jari |
89 |
} |
2 |
26 Feb 07 |
jari |
90 |
|
2 |
26 Feb 07 |
jari |
91 |
class EventListener implements ActionListener, ItemListener, KeyListener { |
2 |
26 Feb 07 |
jari |
92 |
public void actionPerformed(ActionEvent event) { |
2 |
26 Feb 07 |
jari |
93 |
if (event.getSource() == okButton) { |
2 |
26 Feb 07 |
jari |
94 |
String number = numberTextField.getText(); |
2 |
26 Feb 07 |
jari |
95 |
hide(); |
2 |
26 Feb 07 |
jari |
96 |
|
2 |
26 Feb 07 |
jari |
97 |
Hashtable hash = new Hashtable(); |
2 |
26 Feb 07 |
jari |
98 |
hash.put(new String("number"), number); |
2 |
26 Feb 07 |
jari |
99 |
fireEvent(new ActionInfoEvent(this, hash)); |
2 |
26 Feb 07 |
jari |
100 |
|
2 |
26 Feb 07 |
jari |
101 |
dispose(); |
2 |
26 Feb 07 |
jari |
102 |
} |
2 |
26 Feb 07 |
jari |
103 |
} |
2 |
26 Feb 07 |
jari |
104 |
|
2 |
26 Feb 07 |
jari |
105 |
public void itemStateChanged(ItemEvent event) { |
2 |
26 Feb 07 |
jari |
106 |
if (event.getSource() == numberChoice) { |
2 |
26 Feb 07 |
jari |
107 |
numberTextField.setText((String) numberChoice.getSelectedItem()); |
2 |
26 Feb 07 |
jari |
108 |
} |
2 |
26 Feb 07 |
jari |
109 |
} |
2 |
26 Feb 07 |
jari |
110 |
|
2 |
26 Feb 07 |
jari |
111 |
public void keyPressed(KeyEvent event) { |
2 |
26 Feb 07 |
jari |
112 |
if (event.getKeyCode() == KeyEvent.VK_ENTER) { |
2 |
26 Feb 07 |
jari |
113 |
String number = numberTextField.getText(); |
2 |
26 Feb 07 |
jari |
114 |
hide(); |
2 |
26 Feb 07 |
jari |
115 |
|
2 |
26 Feb 07 |
jari |
116 |
Hashtable hash = new Hashtable(); |
2 |
26 Feb 07 |
jari |
117 |
hash.put(new String("number"), number); |
2 |
26 Feb 07 |
jari |
118 |
fireEvent(new ActionInfoEvent(this, hash)); |
2 |
26 Feb 07 |
jari |
119 |
|
2 |
26 Feb 07 |
jari |
120 |
dispose(); |
2 |
26 Feb 07 |
jari |
121 |
} |
2 |
26 Feb 07 |
jari |
122 |
} |
2 |
26 Feb 07 |
jari |
123 |
|
2 |
26 Feb 07 |
jari |
124 |
public void keyReleased(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
125 |
public void keyTyped(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
126 |
} |
2 |
26 Feb 07 |
jari |
127 |
} |