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: SetUpperLimitsDialog.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.4 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/02/23 20:59:41 $ |
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.mev; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Toolkit; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.event.ActionListener; |
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.awt.event.WindowAdapter; |
2 |
26 Feb 07 |
jari |
23 |
import java.awt.event.WindowEvent; |
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.JDialog; |
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.JOptionPane; |
2 |
26 Feb 07 |
jari |
30 |
import javax.swing.JTextField; |
2 |
26 Feb 07 |
jari |
31 |
|
2 |
26 Feb 07 |
jari |
32 |
import org.tigr.util.awt.GBA; |
2 |
26 Feb 07 |
jari |
33 |
|
2 |
26 Feb 07 |
jari |
34 |
public class SetUpperLimitsDialog extends JDialog { |
2 |
26 Feb 07 |
jari |
35 |
|
2 |
26 Feb 07 |
jari |
36 |
private int result; |
2 |
26 Feb 07 |
jari |
37 |
private JTextField cy3TextField, cy5TextField; |
2 |
26 Feb 07 |
jari |
38 |
|
2 |
26 Feb 07 |
jari |
39 |
public SetUpperLimitsDialog(JFrame parent, float xValue, float yValue) { |
2 |
26 Feb 07 |
jari |
40 |
super(parent, "Set Upper Thresholds", true); |
2 |
26 Feb 07 |
jari |
41 |
|
2 |
26 Feb 07 |
jari |
42 |
EventListener listener = new EventListener(); |
2 |
26 Feb 07 |
jari |
43 |
|
2 |
26 Feb 07 |
jari |
44 |
JLabel cy3Label = new JLabel("Max Cy3 (" + xValue + "): "); |
2 |
26 Feb 07 |
jari |
45 |
cy3Label.addKeyListener(listener); |
2 |
26 Feb 07 |
jari |
46 |
|
2 |
26 Feb 07 |
jari |
47 |
cy3TextField = new JTextField(10); |
2 |
26 Feb 07 |
jari |
48 |
cy3TextField.addKeyListener(listener); |
2 |
26 Feb 07 |
jari |
49 |
cy3TextField.setText("" + xValue); |
2 |
26 Feb 07 |
jari |
50 |
|
2 |
26 Feb 07 |
jari |
51 |
JLabel cy5Label = new JLabel("Max Cy5 (" + yValue + "): "); |
2 |
26 Feb 07 |
jari |
52 |
cy5Label.addKeyListener(listener); |
2 |
26 Feb 07 |
jari |
53 |
|
2 |
26 Feb 07 |
jari |
54 |
cy5TextField = new JTextField(10); |
2 |
26 Feb 07 |
jari |
55 |
cy5TextField.addKeyListener(listener); |
2 |
26 Feb 07 |
jari |
56 |
cy5TextField.setText("" + yValue); |
2 |
26 Feb 07 |
jari |
57 |
|
2 |
26 Feb 07 |
jari |
58 |
JButton okButton = new JButton("Ok"); |
2 |
26 Feb 07 |
jari |
59 |
okButton.setActionCommand("ok-command"); |
2 |
26 Feb 07 |
jari |
60 |
okButton.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
61 |
|
2 |
26 Feb 07 |
jari |
62 |
JButton cancelButton = new JButton("Cancel"); |
2 |
26 Feb 07 |
jari |
63 |
cancelButton.setActionCommand("cancel-command"); |
2 |
26 Feb 07 |
jari |
64 |
cancelButton.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
65 |
|
2 |
26 Feb 07 |
jari |
66 |
getContentPane().setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
67 |
GBA gba = new GBA(); |
2 |
26 Feb 07 |
jari |
68 |
gba.add(getContentPane(), cy3Label, 0, 0, 1, 1, 0, 0, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
69 |
gba.add(getContentPane(), cy3TextField, 1, 0, 1, 1, 1, 1, GBA.H, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
70 |
gba.add(getContentPane(), cy5Label, 0, 1, 1, 1, 0, 0, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
71 |
gba.add(getContentPane(), cy5TextField, 1, 1, 1, 1, 1, 1, GBA.H, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
72 |
gba.add(getContentPane(), cancelButton, 0, 2, 1, 1, 0, 0, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
73 |
gba.add(getContentPane(), okButton, 1, 2, 1, 1, 0, 0, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
74 |
addWindowListener(listener); |
2 |
26 Feb 07 |
jari |
75 |
pack(); |
2 |
26 Feb 07 |
jari |
76 |
setResizable(false); |
2 |
26 Feb 07 |
jari |
77 |
cy3TextField.grabFocus(); |
2 |
26 Feb 07 |
jari |
78 |
} |
2 |
26 Feb 07 |
jari |
79 |
|
2 |
26 Feb 07 |
jari |
80 |
public int showModal() { |
2 |
26 Feb 07 |
jari |
81 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
82 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
83 |
show(); |
2 |
26 Feb 07 |
jari |
84 |
return result; |
2 |
26 Feb 07 |
jari |
85 |
} |
2 |
26 Feb 07 |
jari |
86 |
|
2 |
26 Feb 07 |
jari |
87 |
public float getUpperCY3() { |
2 |
26 Feb 07 |
jari |
88 |
return Float.parseFloat(cy3TextField.getText()); |
2 |
26 Feb 07 |
jari |
89 |
} |
2 |
26 Feb 07 |
jari |
90 |
|
2 |
26 Feb 07 |
jari |
91 |
public float getUpperCY5() { |
2 |
26 Feb 07 |
jari |
92 |
return Float.parseFloat(cy5TextField.getText()); |
2 |
26 Feb 07 |
jari |
93 |
} |
2 |
26 Feb 07 |
jari |
94 |
|
2 |
26 Feb 07 |
jari |
95 |
private class EventListener extends WindowAdapter implements ActionListener, KeyListener { |
2 |
26 Feb 07 |
jari |
96 |
public void actionPerformed(ActionEvent event) { |
2 |
26 Feb 07 |
jari |
97 |
String command = event.getActionCommand(); |
2 |
26 Feb 07 |
jari |
98 |
if (command.equals("ok-command")) { |
2 |
26 Feb 07 |
jari |
99 |
try { |
2 |
26 Feb 07 |
jari |
100 |
Float.parseFloat(cy3TextField.getText()); |
2 |
26 Feb 07 |
jari |
101 |
Float.parseFloat(cy5TextField.getText()); |
2 |
26 Feb 07 |
jari |
102 |
result = JOptionPane.OK_OPTION; |
2 |
26 Feb 07 |
jari |
103 |
} catch (Exception exception) { |
2 |
26 Feb 07 |
jari |
104 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
105 |
} |
2 |
26 Feb 07 |
jari |
106 |
dispose(); |
2 |
26 Feb 07 |
jari |
107 |
} else if (command.equals("cancel-command")) { |
2 |
26 Feb 07 |
jari |
108 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
109 |
dispose(); |
2 |
26 Feb 07 |
jari |
110 |
} |
2 |
26 Feb 07 |
jari |
111 |
} |
2 |
26 Feb 07 |
jari |
112 |
|
2 |
26 Feb 07 |
jari |
113 |
public void windowClosing(WindowEvent e) { |
2 |
26 Feb 07 |
jari |
114 |
result = JOptionPane.CLOSED_OPTION; |
2 |
26 Feb 07 |
jari |
115 |
dispose(); |
2 |
26 Feb 07 |
jari |
116 |
} |
2 |
26 Feb 07 |
jari |
117 |
|
2 |
26 Feb 07 |
jari |
118 |
public void keyPressed(KeyEvent event) { |
2 |
26 Feb 07 |
jari |
119 |
if (event.getKeyCode() == KeyEvent.VK_ENTER) { |
2 |
26 Feb 07 |
jari |
120 |
try { |
2 |
26 Feb 07 |
jari |
121 |
Float.parseFloat(cy3TextField.getText()); |
2 |
26 Feb 07 |
jari |
122 |
Float.parseFloat(cy5TextField.getText()); |
2 |
26 Feb 07 |
jari |
123 |
result = JOptionPane.OK_OPTION; |
2 |
26 Feb 07 |
jari |
124 |
} catch (Exception exception) { |
2 |
26 Feb 07 |
jari |
125 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
126 |
} |
2 |
26 Feb 07 |
jari |
127 |
dispose(); |
2 |
26 Feb 07 |
jari |
128 |
} |
2 |
26 Feb 07 |
jari |
129 |
} |
2 |
26 Feb 07 |
jari |
130 |
|
2 |
26 Feb 07 |
jari |
131 |
public void keyReleased(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
132 |
public void keyTyped(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
133 |
} |
2 |
26 Feb 07 |
jari |
134 |
} |