Revision 25736 branches/v2_0_0_prep/libraries/libUIComponent/src/org/gvsig/gui/beans/swing/JIncrementalNumberField.java
JIncrementalNumberField.java | ||
---|---|---|
79 | 79 |
private double maxValue; |
80 | 80 |
private double minValue; |
81 | 81 |
|
82 |
private ActionListener propage = new ActionListener() { |
|
83 |
public void actionPerformed(ActionEvent e) { |
|
84 |
if (!isEnabled()) return; |
|
85 |
if (acceptsDoubles) { |
|
86 |
double v = getDouble(); |
|
87 |
if (v>maxValue) |
|
88 |
v = maxValue; |
|
89 |
if (v<minValue) |
|
90 |
v = minValue; |
|
91 |
setDouble(v); |
|
92 |
} else { |
|
93 |
int v = getInteger(); |
|
94 |
if (v>maxValue) |
|
95 |
v = (int) maxValue; |
|
96 |
if (v<minValue) |
|
97 |
v = (int) minValue; |
|
98 |
setInteger(v); |
|
99 |
} |
|
100 |
fireActionPerformed(e); |
|
101 |
} |
|
102 |
}; |
|
82 | 103 |
|
83 | 104 |
private ActionListener accum = new ActionListener() { |
84 | 105 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
296 | 317 |
validator, |
297 | 318 |
cleaner) ; |
298 | 319 |
setLayout(new BorderLayout(0, 0)); |
320 |
vtf.addActionListener(propage); |
|
299 | 321 |
add(vtf, BorderLayout.CENTER); |
300 | 322 |
add(lateralButtons, BorderLayout.EAST); |
301 | 323 |
} |
... | ... | |
323 | 345 |
} |
324 | 346 |
|
325 | 347 |
public void addActionListener(ActionListener l) { |
326 |
vtf.addActionListener(l); |
|
348 |
// vtf.addActionListener(l);
|
|
327 | 349 |
listeners.add(l); |
328 | 350 |
} |
329 | 351 |
|
330 | 352 |
public void removeActionListener(ActionListener l) { |
331 |
vtf.removeActionListener(l); |
|
353 |
// vtf.removeActionListener(l);
|
|
332 | 354 |
listeners.remove(l); |
333 | 355 |
} |
334 | 356 |
|
... | ... | |
339 | 361 |
} |
340 | 362 |
} |
341 | 363 |
|
364 |
private void fireActionPerformed(ActionEvent e) { |
|
365 |
e.setSource(this); |
|
366 |
for (int i = 0; i < listeners.size(); i++) { |
|
367 |
((ActionListener) listeners.get(i)).actionPerformed(e); |
|
368 |
} |
|
369 |
} |
|
370 |
|
|
342 | 371 |
public double getMaxValue() { |
343 | 372 |
return maxValue; |
344 | 373 |
} |
Also available in: Unified diff