Revision 8127 trunk/libraries/libJCRS/src/org/gvsig/crs/gui/panels/IAU2000panel.java
IAU2000panel.java | ||
---|---|---|
5 | 5 |
import java.awt.FlowLayout; |
6 | 6 |
import java.awt.GridLayout; |
7 | 7 |
import java.awt.event.ActionEvent; |
8 |
import java.awt.event.ActionListener; |
|
8 | 9 |
import java.awt.event.KeyEvent; |
9 | 10 |
import java.awt.event.KeyListener; |
10 | 11 |
import java.sql.ResultSet; |
... | ... | |
32 | 33 |
import com.iver.andami.PluginServices; |
33 | 34 |
import com.iver.cit.gvsig.gui.TableSorter; |
34 | 35 |
|
35 |
public class IAU2000panel extends JPanel { |
|
36 |
public class IAU2000panel extends JPanel implements KeyListener, ActionListener {
|
|
36 | 37 |
|
37 | 38 |
/** |
38 | 39 |
* |
... | ... | |
92 | 93 |
connect.setConnectionIAU2000(); |
93 | 94 |
} |
94 | 95 |
|
95 |
private void searchButton_actionPerformed(ActionEvent e) {
|
|
96 |
private void searchButton() {
|
|
96 | 97 |
searchTextField.setBackground(Color.white); |
97 | 98 |
|
98 | 99 |
if (searchTextField.getText().equals("")) { |
... | ... | |
147 | 148 |
searchButton.setPreferredSize(new Dimension(75,20)); |
148 | 149 |
searchButton.setText(PluginServices.getText(this,"Buscar")); |
149 | 150 |
searchButton.setMnemonic('S'); |
150 |
searchButton.addActionListener(new java.awt.event.ActionListener() { |
|
151 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
152 |
searchTextField.setBackground(Color.white); |
|
153 |
if (searchTextField.getText().equals("")) { |
|
154 |
searchTextField.setBackground(new Color(255,204,204)); |
|
155 |
JOptionPane.showMessageDialog(IAU2000panel.this, |
|
156 |
"Fill the key-word of the search.", |
|
157 |
"Warning...", JOptionPane.WARNING_MESSAGE); |
|
158 |
} |
|
159 |
else { |
|
160 |
searchButton_actionPerformed(e); |
|
161 |
} |
|
162 |
} |
|
163 |
}); |
|
151 |
searchButton.addActionListener(this); |
|
164 | 152 |
} |
165 | 153 |
return searchButton; |
166 | 154 |
} |
... | ... | |
169 | 157 |
if (searchTextField == null) { |
170 | 158 |
searchTextField = new JTextField(); |
171 | 159 |
searchTextField.setPreferredSize(new Dimension(300,20)); |
172 |
} |
|
173 |
searchTextField.addKeyListener(new KeyListener() { |
|
174 |
public void keyPressed(KeyEvent e) { |
|
175 |
if (e.getKeyCode() == 10) { |
|
176 |
searchButton_actionPerformed(null); |
|
177 |
} |
|
178 |
} |
|
179 |
|
|
180 |
public void keyReleased(KeyEvent arg0) { |
|
181 |
} |
|
182 |
|
|
183 |
public void keyTyped(KeyEvent arg0) { |
|
184 |
} |
|
185 |
}); |
|
160 |
searchTextField.addKeyListener(this); |
|
161 |
} |
|
186 | 162 |
return searchTextField; |
187 | 163 |
} |
188 | 164 |
|
... | ... | |
285 | 261 |
} |
286 | 262 |
} |
287 | 263 |
|
264 |
public void keyPressed(KeyEvent e) { |
|
265 |
if (e.getSource() == this.getSearchTextField()){ |
|
266 |
if (e.getKeyCode() == 10) { |
|
267 |
searchButton(); |
|
268 |
} |
|
269 |
|
|
270 |
if ((e.getKeyCode() >= 48 && e.getKeyCode() <= 57) || e.getKeyCode() >= 96 && e.getKeyCode() <= 105 || |
|
271 |
(e.getKeyCode() >= 0 && e.getKeyCode()<= 31) || e.getKeyCode() == 127){ |
|
272 |
} |
|
273 |
else { |
|
274 |
JOptionPane.showMessageDialog(IAU2000panel.this, |
|
275 |
"Only number format.", |
|
276 |
"Warning...", JOptionPane.WARNING_MESSAGE); |
|
277 |
String aux = searchTextField.getText(); |
|
278 |
if (aux.length() == 1 || aux.length() == 0){ |
|
279 |
searchTextField.setText(""); |
|
280 |
} |
|
281 |
else { |
|
282 |
searchTextField.setText(aux.substring(0, aux.length()-1)); |
|
283 |
} |
|
284 |
} |
|
285 |
} |
|
286 |
|
|
287 |
} |
|
288 |
|
|
289 |
public void keyReleased(KeyEvent arg0) { |
|
290 |
// TODO Auto-generated method stub |
|
291 |
|
|
292 |
} |
|
293 |
|
|
294 |
public void keyTyped(KeyEvent arg0) { |
|
295 |
// TODO Auto-generated method stub |
|
296 |
|
|
297 |
} |
|
298 |
|
|
299 |
public void actionPerformed(ActionEvent e) { |
|
300 |
// TODO Auto-generated method stub |
|
301 |
if (e.getSource() == this.getSearchButton()){ |
|
302 |
searchTextField.setBackground(Color.white); |
|
303 |
if (searchTextField.getText().equals("")) { |
|
304 |
searchTextField.setBackground(new Color(255,204,204)); |
|
305 |
JOptionPane.showMessageDialog(IAU2000panel.this, |
|
306 |
"Fill the key-word of the search.", |
|
307 |
"Warning...", JOptionPane.WARNING_MESSAGE); |
|
308 |
} |
|
309 |
else { |
|
310 |
searchButton(); |
|
311 |
} |
|
312 |
} |
|
313 |
} |
|
314 |
|
|
288 | 315 |
} |
Also available in: Unified diff