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: BoundariesDialog.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.4 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/02/23 21:00:04 $ |
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.util.awt; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Font; |
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.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.event.KeyEvent; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.event.KeyListener; |
2 |
26 Feb 07 |
jari |
21 |
import java.util.Hashtable; |
2 |
26 Feb 07 |
jari |
22 |
|
2 |
26 Feb 07 |
jari |
23 |
import javax.swing.JButton; |
2 |
26 Feb 07 |
jari |
24 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
25 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
26 |
import javax.swing.JTextField; |
2 |
26 Feb 07 |
jari |
27 |
|
2 |
26 Feb 07 |
jari |
28 |
public class BoundariesDialog extends ActionInfoDialog { |
2 |
26 Feb 07 |
jari |
29 |
private JFrame parent; |
2 |
26 Feb 07 |
jari |
30 |
JLabel lowerxLabel, upperxLabel, loweryLabel, upperyLabel; |
2 |
26 Feb 07 |
jari |
31 |
JTextField lowerxTextField, upperxTextField, loweryTextField, upperyTextField; |
2 |
26 Feb 07 |
jari |
32 |
JButton okButton, cancelButton; |
2 |
26 Feb 07 |
jari |
33 |
Font boundariesDialogFont; |
2 |
26 Feb 07 |
jari |
34 |
GBA gba; |
2 |
26 Feb 07 |
jari |
35 |
|
2 |
26 Feb 07 |
jari |
36 |
public BoundariesDialog(JFrame parent, double lowerx, double upperx, double lowery, double uppery) { |
2 |
26 Feb 07 |
jari |
37 |
super(parent, true); |
2 |
26 Feb 07 |
jari |
38 |
try { |
2 |
26 Feb 07 |
jari |
39 |
this.parent = parent; |
2 |
26 Feb 07 |
jari |
40 |
gba = new GBA(); |
2 |
26 Feb 07 |
jari |
41 |
|
2 |
26 Feb 07 |
jari |
42 |
lowerxLabel = new JLabel("Lower X: (" + lowerx + ")"); |
2 |
26 Feb 07 |
jari |
43 |
upperxLabel = new JLabel("Upper X: (" + upperx + ")"); |
2 |
26 Feb 07 |
jari |
44 |
loweryLabel = new JLabel("Lower Y: (" + lowery + ")"); |
2 |
26 Feb 07 |
jari |
45 |
upperyLabel = new JLabel("Upper Y: (" + uppery + ")"); |
2 |
26 Feb 07 |
jari |
46 |
|
2 |
26 Feb 07 |
jari |
47 |
lowerxTextField = new JTextField(12); |
2 |
26 Feb 07 |
jari |
48 |
lowerxTextField.setText("" + lowerx); |
2 |
26 Feb 07 |
jari |
49 |
upperxTextField = new JTextField(12); |
2 |
26 Feb 07 |
jari |
50 |
upperxTextField.setText("" + upperx); |
2 |
26 Feb 07 |
jari |
51 |
loweryTextField = new JTextField(12); |
2 |
26 Feb 07 |
jari |
52 |
loweryTextField.setText("" + lowery); |
2 |
26 Feb 07 |
jari |
53 |
upperyTextField = new JTextField(12); |
2 |
26 Feb 07 |
jari |
54 |
upperyTextField.setText("" + uppery); |
2 |
26 Feb 07 |
jari |
55 |
|
2 |
26 Feb 07 |
jari |
56 |
okButton = new JButton("OK"); |
2 |
26 Feb 07 |
jari |
57 |
okButton.addActionListener(new EventListener()); |
2 |
26 Feb 07 |
jari |
58 |
cancelButton = new JButton("Cancel"); |
2 |
26 Feb 07 |
jari |
59 |
cancelButton.addActionListener(new EventListener()); |
2 |
26 Feb 07 |
jari |
60 |
|
2 |
26 Feb 07 |
jari |
61 |
contentPane.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
62 |
|
2 |
26 Feb 07 |
jari |
63 |
gba.add(contentPane, upperyLabel, 1, 0, 1, 1, 1, 1, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
64 |
gba.add(contentPane, lowerxLabel, 0, 1, 1, 1, 1, 1, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
65 |
gba.add(contentPane, upperyTextField, 1, 1, 1, 1, 1, 1, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
66 |
gba.add(contentPane, upperxLabel, 2, 1, 1, 1, 1, 1, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
67 |
gba.add(contentPane, lowerxTextField, 0, 2, 1, 1, 1, 1, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
68 |
gba.add(contentPane, loweryLabel, 1, 2, 1, 1, 1, 1, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
69 |
gba.add(contentPane, upperxTextField, 2, 2, 1, 1, 1, 1, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
70 |
gba.add(contentPane, cancelButton, 0, 3, 1, 1, 1, 1, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
71 |
gba.add(contentPane, loweryTextField, 1, 3, 1, 1, 1, 1, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
72 |
gba.add(contentPane, okButton, 2, 3, 1, 1, 1, 1, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
73 |
|
2 |
26 Feb 07 |
jari |
74 |
pack(); |
2 |
26 Feb 07 |
jari |
75 |
setResizable(false); |
2 |
26 Feb 07 |
jari |
76 |
setTitle("Set Graph Boundaries"); |
2 |
26 Feb 07 |
jari |
77 |
okButton.grabFocus(); |
2 |
26 Feb 07 |
jari |
78 |
setLocation(300, 300); |
2 |
26 Feb 07 |
jari |
79 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
80 |
System.out.println("Exception (DatabaseLoginDialog.const()): " + e); |
2 |
26 Feb 07 |
jari |
81 |
} |
2 |
26 Feb 07 |
jari |
82 |
} |
2 |
26 Feb 07 |
jari |
83 |
|
2 |
26 Feb 07 |
jari |
84 |
class EventListener implements ActionListener, KeyListener { |
2 |
26 Feb 07 |
jari |
85 |
public void actionPerformed(ActionEvent event) { |
2 |
26 Feb 07 |
jari |
86 |
if (event.getSource() == okButton) { |
2 |
26 Feb 07 |
jari |
87 |
String lowerx = lowerxTextField.getText(); |
2 |
26 Feb 07 |
jari |
88 |
String upperx = upperxTextField.getText(); |
2 |
26 Feb 07 |
jari |
89 |
String lowery = loweryTextField.getText(); |
2 |
26 Feb 07 |
jari |
90 |
String uppery = upperyTextField.getText(); |
2 |
26 Feb 07 |
jari |
91 |
hide(); |
2 |
26 Feb 07 |
jari |
92 |
|
2 |
26 Feb 07 |
jari |
93 |
Hashtable hash = new Hashtable(); |
2 |
26 Feb 07 |
jari |
94 |
hash.put(new String("lowerx"), lowerx); |
2 |
26 Feb 07 |
jari |
95 |
hash.put(new String("upperx"), upperx); |
2 |
26 Feb 07 |
jari |
96 |
hash.put(new String("lowery"), lowery); |
2 |
26 Feb 07 |
jari |
97 |
hash.put(new String("uppery"), uppery); |
2 |
26 Feb 07 |
jari |
98 |
|
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 |
} else if (event.getSource() == cancelButton) dispose(); |
2 |
26 Feb 07 |
jari |
103 |
} |
2 |
26 Feb 07 |
jari |
104 |
|
2 |
26 Feb 07 |
jari |
105 |
public void keyPressed(KeyEvent event) { |
2 |
26 Feb 07 |
jari |
106 |
if (event.getKeyCode() == KeyEvent.VK_ENTER) { |
2 |
26 Feb 07 |
jari |
107 |
String lowerx = lowerxTextField.getText(); |
2 |
26 Feb 07 |
jari |
108 |
String upperx = upperxTextField.getText(); |
2 |
26 Feb 07 |
jari |
109 |
String lowery = loweryTextField.getText(); |
2 |
26 Feb 07 |
jari |
110 |
String uppery = upperyTextField.getText(); |
2 |
26 Feb 07 |
jari |
111 |
hide(); |
2 |
26 Feb 07 |
jari |
112 |
|
2 |
26 Feb 07 |
jari |
113 |
Hashtable hash = new Hashtable(); |
2 |
26 Feb 07 |
jari |
114 |
hash.put(new String("lowerx"), lowerx); |
2 |
26 Feb 07 |
jari |
115 |
hash.put(new String("upperx"), upperx); |
2 |
26 Feb 07 |
jari |
116 |
hash.put(new String("lowery"), lowery); |
2 |
26 Feb 07 |
jari |
117 |
hash.put(new String("uppery"), uppery); |
2 |
26 Feb 07 |
jari |
118 |
|
2 |
26 Feb 07 |
jari |
119 |
fireEvent(new ActionInfoEvent(this, hash)); |
2 |
26 Feb 07 |
jari |
120 |
|
2 |
26 Feb 07 |
jari |
121 |
dispose(); |
2 |
26 Feb 07 |
jari |
122 |
} |
2 |
26 Feb 07 |
jari |
123 |
} |
2 |
26 Feb 07 |
jari |
124 |
|
2 |
26 Feb 07 |
jari |
125 |
public void keyReleased(KeyEvent event) {} |
2 |
26 Feb 07 |
jari |
126 |
public void keyTyped(KeyEvent event) {} |
2 |
26 Feb 07 |
jari |
127 |
} |
2 |
26 Feb 07 |
jari |
128 |
} |