71 |
public abstract class AbstractButton extends JComponent |
public abstract class AbstractButton extends JComponent |
72 |
implements ItemSelectable, SwingConstants |
implements ItemSelectable, SwingConstants |
73 |
{ |
{ |
74 |
Icon default_icon, pressed_button, disabled_button, |
Icon default_icon, pressed_button, disabled_button, |
75 |
selected_button, disabled_selected_button, current_icon; |
selected_button, disabled_selected_button, current_icon; |
76 |
String text; |
String text; |
77 |
|
|
78 |
int vert_align = CENTER; |
int vert_align = CENTER; |
79 |
int hori_align = CENTER; |
int hori_align = CENTER; |
80 |
int hori_text_pos = CENTER; |
int hori_text_pos = CENTER; |
81 |
int vert_text_pos = CENTER; |
int vert_text_pos = CENTER; |
82 |
|
|
83 |
boolean paint_border = true, paint_focus; |
boolean paint_border = true, paint_focus; |
84 |
Action action_taken; |
Action action_taken; |
85 |
ButtonModel model; |
ButtonModel model; |
86 |
Insets margin; |
Insets margin; |
87 |
|
|
88 |
|
public static final String FOCUS_PAINTED_CHANGED_PROPERTY = "focusPainted"; |
89 |
public static final String FOCUS_PAINTED_CHANGED_PROPERTY = "focusPainted"; |
|
90 |
|
/** |
91 |
/** |
* AccessibleAbstractButton |
92 |
* AccessibleAbstractButton |
*/ |
93 |
*/ |
protected abstract class AccessibleAbstractButton |
94 |
protected abstract class AccessibleAbstractButton |
extends AccessibleJComponent |
95 |
extends AccessibleJComponent |
implements AccessibleAction, AccessibleValue, AccessibleText { |
96 |
implements AccessibleAction, AccessibleValue, AccessibleText { |
|
97 |
|
/** |
98 |
//------------------------------------------------------------- |
* Constructor AccessibleAbstractButton |
99 |
// Initialization --------------------------------------------- |
* @param component TODO |
100 |
//------------------------------------------------------------- |
*/ |
101 |
|
protected AccessibleAbstractButton(AbstractButton component) { |
102 |
/** |
super(component); |
103 |
* Constructor AccessibleAbstractButton |
// TODO |
104 |
* @param component TODO |
} // AccessibleAbstractButton() |
105 |
*/ |
|
106 |
protected AccessibleAbstractButton(AbstractButton component) { |
/** |
107 |
super(component); |
* getAccessibleStateSet |
108 |
// TODO |
* @returns AccessibleStateSet |
109 |
} // AccessibleAbstractButton() |
*/ |
110 |
|
public AccessibleStateSet getAccessibleStateSet() { |
111 |
|
return null; // TODO |
112 |
//------------------------------------------------------------- |
} // getAccessibleStateSet() |
113 |
// Methods ---------------------------------------------------- |
|
114 |
//------------------------------------------------------------- |
/** |
115 |
|
* getAccessibleName |
116 |
/** |
* @returns String |
117 |
* getAccessibleStateSet |
*/ |
118 |
* @returns AccessibleStateSet |
public String getAccessibleName() { |
119 |
*/ |
return null; // TODO |
120 |
public AccessibleStateSet getAccessibleStateSet() { |
} // getAccessibleName() |
121 |
return null; // TODO |
|
122 |
} // getAccessibleStateSet() |
/** |
123 |
|
* getAccessibleIcon |
124 |
/** |
* @returns AccessibleIcon[] |
125 |
* getAccessibleName |
*/ |
126 |
* @returns String |
public AccessibleIcon[] getAccessibleIcon() { |
127 |
*/ |
return null; // TODO |
128 |
public String getAccessibleName() { |
} // getAccessibleIcon() |
129 |
return null; // TODO |
|
130 |
} // getAccessibleName() |
/** |
131 |
|
* getAccessibleRelationSet |
132 |
/** |
* @returns AccessibleRelationSet |
133 |
* getAccessibleIcon |
*/ |
134 |
* @returns AccessibleIcon[] |
public AccessibleRelationSet getAccessibleRelationSet() { |
135 |
*/ |
return null; // TODO |
136 |
public AccessibleIcon[] getAccessibleIcon() { |
} // getAccessibleRelationSet() |
137 |
return null; // TODO |
|
138 |
} // getAccessibleIcon() |
/** |
139 |
|
* getAccessibleAction |
140 |
/** |
* @returns AccessibleAction |
141 |
* getAccessibleRelationSet |
*/ |
142 |
* @returns AccessibleRelationSet |
public AccessibleAction getAccessibleAction() { |
143 |
*/ |
return null; // TODO |
144 |
public AccessibleRelationSet getAccessibleRelationSet() { |
} // getAccessibleAction() |
145 |
return null; // TODO |
|
146 |
} // getAccessibleRelationSet() |
/** |
147 |
|
* getAccessibleValue |
148 |
/** |
* @returns AccessibleValue |
149 |
* getAccessibleAction |
*/ |
150 |
* @returns AccessibleAction |
public AccessibleValue getAccessibleValue() { |
151 |
*/ |
return null; // TODO |
152 |
public AccessibleAction getAccessibleAction() { |
} // getAccessibleValue() |
153 |
return null; // TODO |
|
154 |
} // getAccessibleAction() |
/** |
155 |
|
* getAccessibleActionCount |
156 |
/** |
* @returns int |
157 |
* getAccessibleValue |
*/ |
158 |
* @returns AccessibleValue |
public int getAccessibleActionCount() { |
159 |
*/ |
return 0; // TODO |
160 |
public AccessibleValue getAccessibleValue() { |
} // getAccessibleActionCount() |
161 |
return null; // TODO |
|
162 |
} // getAccessibleValue() |
/** |
163 |
|
* getAccessibleActionDescription |
164 |
/** |
* @param value0 TODO |
165 |
* getAccessibleActionCount |
* @returns String |
166 |
* @returns int |
*/ |
167 |
*/ |
public String getAccessibleActionDescription(int value0) { |
168 |
public int getAccessibleActionCount() { |
return null; // TODO |
169 |
return 0; // TODO |
} // getAccessibleActionDescription() |
170 |
} // getAccessibleActionCount() |
|
171 |
|
/** |
172 |
/** |
* doAccessibleAction |
173 |
* getAccessibleActionDescription |
* @param value0 TODO |
174 |
* @param value0 TODO |
* @returns boolean |
175 |
* @returns String |
*/ |
176 |
*/ |
public boolean doAccessibleAction(int value0) { |
177 |
public String getAccessibleActionDescription(int value0) { |
return false; // TODO |
178 |
return null; // TODO |
} // doAccessibleAction() |
179 |
} // getAccessibleActionDescription() |
|
180 |
|
/** |
181 |
/** |
* getCurrentAccessibleValue |
182 |
* doAccessibleAction |
* @returns Number |
183 |
* @param value0 TODO |
*/ |
184 |
* @returns boolean |
public Number getCurrentAccessibleValue() { |
185 |
*/ |
return null; // TODO |
186 |
public boolean doAccessibleAction(int value0) { |
} // getCurrentAccessibleValue() |
187 |
return false; // TODO |
|
188 |
} // doAccessibleAction() |
/** |
189 |
|
* setCurrentAccessibleValue |
190 |
/** |
* @param value0 TODO |
191 |
* getCurrentAccessibleValue |
* @returns boolean |
192 |
* @returns Number |
*/ |
193 |
*/ |
public boolean setCurrentAccessibleValue(Number value0) { |
194 |
public Number getCurrentAccessibleValue() { |
return false; // TODO |
195 |
return null; // TODO |
} // setCurrentAccessibleValue() |
196 |
} // getCurrentAccessibleValue() |
|
197 |
|
/** |
198 |
/** |
* getMinimumAccessibleValue |
199 |
* setCurrentAccessibleValue |
* @returns Number |
200 |
* @param value0 TODO |
*/ |
201 |
* @returns boolean |
public Number getMinimumAccessibleValue() { |
202 |
*/ |
return null; // TODO |
203 |
public boolean setCurrentAccessibleValue(Number value0) { |
} // getMinimumAccessibleValue() |
204 |
return false; // TODO |
|
205 |
} // setCurrentAccessibleValue() |
/** |
206 |
|
* getMaximumAccessibleValue |
207 |
/** |
* @returns Number |
208 |
* getMinimumAccessibleValue |
*/ |
209 |
* @returns Number |
public Number getMaximumAccessibleValue() { |
210 |
*/ |
return null; // TODO |
211 |
public Number getMinimumAccessibleValue() { |
} // getMaximumAccessibleValue() |
212 |
return null; // TODO |
|
213 |
} // getMinimumAccessibleValue() |
/** |
214 |
|
* getAccessibleText |
215 |
/** |
* @returns AccessibleText |
216 |
* getMaximumAccessibleValue |
*/ |
217 |
* @returns Number |
public AccessibleText getAccessibleText() { |
218 |
*/ |
return null; // TODO |
219 |
public Number getMaximumAccessibleValue() { |
} // getAccessibleText() |
220 |
return null; // TODO |
|
221 |
} // getMaximumAccessibleValue() |
/** |
222 |
|
* getIndexAtPoint |
223 |
/** |
* @param value0 TODO |
224 |
* getAccessibleText |
* @returns int |
225 |
* @returns AccessibleText |
*/ |
226 |
*/ |
public int getIndexAtPoint(Point value0) { |
227 |
public AccessibleText getAccessibleText() { |
return 0; // TODO |
228 |
return null; // TODO |
} // getIndexAtPoint() |
229 |
} // getAccessibleText() |
|
230 |
|
/** |
231 |
/** |
* getCharacterBounds |
232 |
* getIndexAtPoint |
* @param value0 TODO |
233 |
* @param value0 TODO |
* @returns Rectangle |
234 |
* @returns int |
*/ |
235 |
*/ |
public Rectangle getCharacterBounds(int value0) { |
236 |
public int getIndexAtPoint(Point value0) { |
return null; // TODO |
237 |
return 0; // TODO |
} // getCharacterBounds() |
238 |
} // getIndexAtPoint() |
|
239 |
|
/** |
240 |
/** |
* getCharCount |
241 |
* getCharacterBounds |
* @returns int |
242 |
* @param value0 TODO |
*/ |
243 |
* @returns Rectangle |
public int getCharCount() { |
244 |
*/ |
return 0; // TODO |
245 |
public Rectangle getCharacterBounds(int value0) { |
} // getCharCount() |
246 |
return null; // TODO |
|
247 |
} // getCharacterBounds() |
/** |
248 |
|
* getCaretPosition |
249 |
/** |
* @returns int |
250 |
* getCharCount |
*/ |
251 |
* @returns int |
public int getCaretPosition() { |
252 |
*/ |
return 0; // TODO |
253 |
public int getCharCount() { |
} // getCaretPosition() |
254 |
return 0; // TODO |
|
255 |
} // getCharCount() |
/** |
256 |
|
* getAtIndex |
257 |
/** |
* @param value0 TODO |
258 |
* getCaretPosition |
* @param value1 TODO |
259 |
* @returns int |
* @returns String |
260 |
*/ |
*/ |
261 |
public int getCaretPosition() { |
public String getAtIndex(int value0, int value1) { |
262 |
return 0; // TODO |
return null; // TODO |
263 |
} // getCaretPosition() |
} // getAtIndex() |
264 |
|
|
265 |
/** |
/** |
266 |
* getAtIndex |
* getAfterIndex |
267 |
* @param value0 TODO |
* @param value0 TODO |
268 |
* @param value1 TODO |
* @param value1 TODO |
269 |
* @returns String |
* @returns String |
270 |
*/ |
*/ |
271 |
public String getAtIndex(int value0, int value1) { |
public String getAfterIndex(int value0, int value1) { |
272 |
return null; // TODO |
return null; // TODO |
273 |
} // getAtIndex() |
} // getAfterIndex() |
274 |
|
|
275 |
/** |
/** |
276 |
* getAfterIndex |
* getBeforeIndex |
277 |
* @param value0 TODO |
* @param value0 TODO |
278 |
* @param value1 TODO |
* @param value1 TODO |
279 |
* @returns String |
* @returns String |
280 |
*/ |
*/ |
281 |
public String getAfterIndex(int value0, int value1) { |
public String getBeforeIndex(int value0, int value1) { |
282 |
return null; // TODO |
return null; // TODO |
283 |
} // getAfterIndex() |
} // getBeforeIndex() |
284 |
|
|
285 |
/** |
/** |
286 |
* getBeforeIndex |
* getCharacterAttribute |
287 |
* @param value0 TODO |
* @param value0 TODO |
288 |
* @param value1 TODO |
* @returns AttributeSet |
289 |
* @returns String |
*/ |
290 |
*/ |
public AttributeSet getCharacterAttribute(int value0) { |
291 |
public String getBeforeIndex(int value0, int value1) { |
return null; // TODO |
292 |
return null; // TODO |
} // getCharacterAttribute() |
293 |
} // getBeforeIndex() |
|
294 |
|
/** |
295 |
/** |
* getSelectionStart |
296 |
* getCharacterAttribute |
* @returns int |
297 |
* @param value0 TODO |
*/ |
298 |
* @returns AttributeSet |
public int getSelectionStart() { |
299 |
*/ |
return 0; // TODO |
300 |
public AttributeSet getCharacterAttribute(int value0) { |
} // getSelectionStart() |
301 |
return null; // TODO |
|
302 |
} // getCharacterAttribute() |
/** |
303 |
|
* getSelectionEnd |
304 |
/** |
* @returns int |
305 |
* getSelectionStart |
*/ |
306 |
* @returns int |
public int getSelectionEnd() { |
307 |
*/ |
return 0; // TODO |
308 |
public int getSelectionStart() { |
} // getSelectionEnd() |
309 |
return 0; // TODO |
|
310 |
} // getSelectionStart() |
/** |
311 |
|
* getSelectedText |
312 |
/** |
* @returns String |
313 |
* getSelectionEnd |
*/ |
314 |
* @returns int |
public String getSelectedText() { |
315 |
*/ |
return null; // TODO |
316 |
public int getSelectionEnd() { |
} // getSelectedText() |
317 |
return 0; // TODO |
|
318 |
} // getSelectionEnd() |
/** |
319 |
|
* getTextRectangle |
320 |
/** |
* @returns Rectangle |
321 |
* getSelectedText |
*/ |
322 |
* @returns String |
private Rectangle getTextRectangle() { |
323 |
*/ |
return null; // TODO |
324 |
public String getSelectedText() { |
} // getTextRectangle() |
325 |
return null; // TODO |
|
326 |
} // getSelectedText() |
|
327 |
|
} // AccessibleAbstractButton |
328 |
/** |
|
329 |
* getTextRectangle |
|
330 |
* @returns Rectangle |
static private class JFocusListener implements FocusListener |
331 |
*/ |
{ |
332 |
private Rectangle getTextRectangle() { |
AbstractButton c; |
333 |
return null; // TODO |
|
334 |
} // getTextRectangle() |
JFocusListener(AbstractButton c) |
335 |
|
{ |
336 |
|
this.c = c; |
337 |
} // AccessibleAbstractButton |
} |
338 |
|
|
339 |
|
public void focusLost(FocusEvent event) |
340 |
static private class JFocusListener implements FocusListener |
{ |
341 |
{ |
c.getModel().setArmed(false); |
342 |
AbstractButton c; |
|
343 |
|
System.out.println("LOST FOCUS"); |
344 |
JFocusListener(AbstractButton c) |
if (c.isFocusPainted()) |
345 |
{ |
{ |
346 |
this.c = c; |
c.repaint(); |
347 |
} |
} |
348 |
|
} |
349 |
public void focusLost(FocusEvent event) |
public void focusGained(FocusEvent event) |
350 |
{ |
{ |
351 |
c.getModel().setArmed(false); |
System.out.println("GAIN FOCUS"); |
352 |
|
} |
353 |
System.out.println("LOST FOCUS"); |
} |
354 |
if (c.isFocusPainted()) |
|
355 |
{ |
AbstractButton() |
356 |
c.repaint(); |
{ |
357 |
} |
this("",null); |
358 |
} |
} |
359 |
public void focusGained(FocusEvent event) |
|
360 |
{ |
AbstractButton(String text, |
361 |
System.out.println("GAIN FOCUS"); |
Icon icon) |
362 |
} |
{ |
363 |
} |
this.text = text; |
364 |
|
setIcon(icon); |
365 |
|
|
366 |
/********************************************** |
setAlignmentX(LEFT_ALIGNMENT); |
367 |
* |
setAlignmentY(CENTER_ALIGNMENT); |
368 |
* |
|
369 |
* Constructors |
addFocusListener( new JFocusListener(this) ); |
370 |
* |
|
371 |
* |
setModel(new DefaultButtonModel(this)); |
372 |
****************/ |
|
373 |
|
updateUI(); // get a proper ui |
374 |
AbstractButton() |
} |
375 |
{ |
|
376 |
this("",null); |
public ButtonModel getModel() |
377 |
} |
{ return model; } |
378 |
|
|
379 |
AbstractButton(String text, |
public void setModel(ButtonModel newModel) |
380 |
Icon icon) |
{ model = newModel; } |
381 |
{ |
|
382 |
this.text = text; |
public String getActionCommand() |
383 |
setIcon(icon); |
{ return getModel().getActionCommand(); } |
384 |
|
|
385 |
setAlignmentX(LEFT_ALIGNMENT); |
public void setActionCommand(String aCommand) |
386 |
setAlignmentY(CENTER_ALIGNMENT); |
{ getModel().setActionCommand(aCommand); } |
387 |
|
|
388 |
addFocusListener( new JFocusListener(this) ); |
public void addActionListener(ActionListener l) |
389 |
|
{ getModel().addActionListener(l); } |
390 |
setModel(new DefaultButtonModel(this)); |
|
391 |
|
public void removeActionListener(ActionListener l) |
392 |
updateUI(); // get a proper ui |
{ getModel().removeActionListener(l); } |
393 |
} |
|
394 |
|
public void addChangeListener(ChangeListener l) |
395 |
|
{ getModel().addChangeListener(l); } |
396 |
/********************************************** |
|
397 |
* |
public void removeChangeListener(ChangeListener l) |
398 |
* |
{ getModel().removeChangeListener(l); } |
399 |
* Actions etc |
|
400 |
* |
public void addItemListener(ItemListener l) |
401 |
* |
{ getModel().addItemListener(l); } |
402 |
****************/ |
|
403 |
|
public void removeItemListener(ItemListener l) |
404 |
public ButtonModel getModel() |
{ getModel().removeItemListener(l); } |
405 |
{ return model; } |
|
406 |
public void setModel(ButtonModel newModel) |
public int getHorizontalAlignment() |
407 |
{ model = newModel; } |
{ return hori_align; } |
408 |
|
|
409 |
public String getActionCommand() |
public int getHorizontalTextPosition() |
410 |
{ return getModel().getActionCommand(); } |
{ return hori_text_pos; } |
411 |
public void setActionCommand(String aCommand) |
|
412 |
{ getModel().setActionCommand(aCommand); } |
public int getVerticalAlignment() |
413 |
|
{ return vert_align; } |
414 |
public void addActionListener(ActionListener l) |
|
415 |
{ getModel().addActionListener(l); } |
public int getVerticalTextPosition() |
416 |
public void removeActionListener(ActionListener l) |
{ return vert_text_pos; } |
417 |
{ getModel().removeActionListener(l); } |
|
418 |
|
protected void fireItemStateChanged(ItemEvent event) |
419 |
public void addChangeListener(ChangeListener l) |
{ |
420 |
{ getModel().addChangeListener(l); } |
} |
421 |
public void removeChangeListener(ChangeListener l) |
|
422 |
{ getModel().removeChangeListener(l); } |
protected void fireStateChanged(ChangeEvent event) |
423 |
|
{ |
424 |
public void addItemListener(ItemListener l) |
} |
425 |
{ getModel().addItemListener(l); } |
|
426 |
public void removeItemListener(ItemListener l) |
protected void fireActionPerformed(ActionEvent event) |
427 |
{ getModel().removeItemListener(l); } |
{ |
428 |
|
} |
429 |
public int getHorizontalAlignment() |
|
430 |
{ return hori_align; } |
public void setVerticalAlignment(int alignment) |
431 |
public int getHorizontalTextPosition() |
{ vert_align = alignment; } |
432 |
{ return hori_text_pos; } |
|
433 |
public int getVerticalAlignment() |
public void setHorizontalAlignment(int alignment) |
434 |
{ return vert_align; } |
{ hori_align = alignment; } |
435 |
public int getVerticalTextPosition() |
|
436 |
{ return vert_text_pos; } |
public void setVerticalTextPosition(int textPosition) |
437 |
|
{ vert_text_pos = textPosition; } |
438 |
|
|
439 |
protected void fireItemStateChanged(ItemEvent event) |
public void setHorizontalTextPosition(int textPosition) |
440 |
{ getModel().fireItemStateChanged(event); } |
{ hori_text_pos = textPosition; } |
441 |
protected void fireStateChanged(ChangeEvent event) |
|
442 |
{ getModel().fireStateChanged(event); } |
public int getMnemonic() |
443 |
protected void fireActionPerformed(ActionEvent event) |
{ return getModel().getMnemonic(); } |
444 |
{ getModel().fireActionPerformed(event); } |
|
445 |
|
public void setMnemonic(char mne) |
446 |
public void setVerticalAlignment(int alignment) |
{ getModel().setMnemonic(mne); } |
447 |
{ vert_align = alignment; } |
|
448 |
public void setHorizontalAlignment(int alignment) |
public void setMnemonic(int mne) |
449 |
{ hori_align = alignment; } |
{ getModel().setMnemonic(mne); } |
450 |
public void setVerticalTextPosition(int textPosition) |
|
451 |
{ vert_text_pos = textPosition; } |
public void setRolloverEnabled(boolean b) |
452 |
public void setHorizontalTextPosition(int textPosition) |
{ getModel().setRollover(b); } |
453 |
{ hori_text_pos = textPosition; } |
|
454 |
|
public boolean isRolloverEnabled() |
455 |
public int getMnemonic() |
{ return getModel().isRollover(); } |
456 |
{ return getModel().getMnemonic(); } |
|
457 |
public void setMnemonic(char mne) |
public boolean isBorderPainted() |
458 |
{ getModel().setMnemonic(mne); } |
{ return paint_border; } |
459 |
public void setMnemonic(int mne) |
|
460 |
{ getModel().setMnemonic(mne); } |
public void setBorderPainted(boolean b) |
461 |
|
{ |
462 |
public void setRolloverEnabled(boolean b) |
if (b != paint_border) |
463 |
{ getModel().setRollover(b); } |
{ |
464 |
public boolean isRolloverEnabled() |
paint_border = b; |
465 |
{ return getModel().isRollover(); } |
revalidate(); |
466 |
|
repaint(); |
467 |
|
} |
468 |
public boolean isBorderPainted() |
} |
469 |
{ return paint_border; } |
|
470 |
public void setBorderPainted(boolean b) |
public Action getAction() |
471 |
{ |
{ return action_taken; } |
472 |
if (b != paint_border) |
|
473 |
{ |
public void setAction(Action a) |
474 |
paint_border = b; |
{ |
475 |
revalidate(); |
action_taken = a; |
476 |
repaint(); |
revalidate(); |
477 |
} |
repaint(); |
478 |
} |
} |
479 |
|
|
480 |
public Action getAction() |
public void setSelected(boolean b) |
481 |
{ return action_taken; } |
{ getModel().setSelected(b); } |
482 |
public void setAction(Action a) |
|
483 |
{ |
public boolean isSelected() |
484 |
action_taken = a; |
{ return getModel().isSelected(); } |
485 |
revalidate(); |
|
486 |
repaint(); |
public Icon getIcon() |
487 |
} |
{ return default_icon; } |
488 |
|
|
489 |
public void setSelected(boolean b) |
public void setIcon(Icon defaultIcon) |
490 |
{ getModel().setSelected(b); } |
{ |
491 |
public boolean isSelected() |
if (default_icon == defaultIcon) |
492 |
{ return getModel().isSelected(); } |
return; |
493 |
|
|
494 |
|
default_icon = defaultIcon; |
495 |
public Icon getIcon() |
if (default_icon != null) |
496 |
{ return default_icon; } |
{ |
497 |
public void setIcon(Icon defaultIcon) |
// XXX FIXME - icons do not know their parent |
498 |
{ |
// default_icon.setParent(this); |
499 |
if (default_icon == defaultIcon) |
} |
500 |
return; |
revalidate(); |
501 |
|
repaint(); |
502 |
default_icon = defaultIcon; |
} |
503 |
if (default_icon != null) |
|
504 |
{ |
public String getText() |
505 |
// XXX FIXME - icons do not know their parent |
{ return text; } |
506 |
// default_icon.setParent(this); |
|
507 |
} |
public void setLabel(String label) |
508 |
revalidate(); |
{ setText(label); } |
509 |
repaint(); |
|
510 |
} |
public String getLabel() |
511 |
|
{ return getText(); } |
512 |
public String getText() |
|
513 |
{ return text; } |
public void setText(String text) |
514 |
public void setLabel(String label) |
{ |
515 |
{ setText(label); } |
this.text = text; |
516 |
public String getLabel() |
revalidate(); |
517 |
{ return getText(); } |
repaint(); |
518 |
public void setText(String text) |
} |
519 |
{ |
|
520 |
this.text = text; |
public Insets getMargin() |
521 |
revalidate(); |
{ return margin; } |
522 |
repaint(); |
|
523 |
} |
public void setMargin(Insets m) |
524 |
|
{ |
525 |
|
margin = m; |
526 |
public Insets getMargin() |
revalidate(); |
527 |
{ return margin; } |
repaint(); |
528 |
public void setMargin(Insets m) |
} |
529 |
{ |
|
530 |
margin = m; |
public void setEnabled(boolean b) |
531 |
revalidate(); |
{ |
532 |
repaint(); |
super.setEnabled(b); |
533 |
} |
getModel().setEnabled(b); |
534 |
|
repaint(); |
535 |
public void setEnabled(boolean b) |
} |
536 |
{ |
|
537 |
super.setEnabled(b); |
public Icon getPressedIcon() |
538 |
getModel().setEnabled(b); |
{ return pressed_button; } |
539 |
repaint(); |
|
540 |
} |
public void setPressedIcon(Icon pressedIcon) |
541 |
|
{ |
542 |
public Icon getPressedIcon() |
pressed_button = pressedIcon; |
543 |
{ return pressed_button; } |
revalidate(); |
544 |
public void setPressedIcon(Icon pressedIcon) |
repaint(); |
545 |
{ |
} |
546 |
pressed_button = pressedIcon; |
|
547 |
revalidate(); |
public Icon getDisabledIcon() |
548 |
repaint(); |
{ return disabled_button; } |
549 |
} |
|
550 |
|
public void setDisabledIcon(Icon disabledIcon) |
551 |
|
{ |
552 |
public Icon getDisabledIcon() |
disabled_button = disabledIcon; |
553 |
{ return disabled_button; } |
revalidate(); |
554 |
public void setDisabledIcon(Icon disabledIcon) |
repaint(); |
555 |
{ |
} |
556 |
disabled_button = disabledIcon; |
|
557 |
revalidate(); |
public boolean isFocusPainted() |
558 |
repaint(); |
{ return paint_focus; } |
559 |
} |
|
560 |
|
public void setFocusPainted(boolean b) |
561 |
public boolean isFocusPainted() |
{ |
562 |
{ return paint_focus; } |
boolean old = paint_focus; |
563 |
public void setFocusPainted(boolean b) |
paint_focus = b; |
564 |
{ |
|
565 |
boolean old = paint_focus; |
firePropertyChange(FOCUS_PAINTED_CHANGED_PROPERTY, |
566 |
paint_focus = b; |
old, |
567 |
|
b); |
568 |
firePropertyChange(FOCUS_PAINTED_CHANGED_PROPERTY, |
if (hasFocus()) |
569 |
old, |
{ |
570 |
b); |
revalidate(); |
571 |
if (hasFocus()) |
repaint(); |
572 |
{ |
} |
573 |
revalidate(); |
} |
574 |
repaint(); |
|
575 |
} |
public boolean isFocusTraversable() |
576 |
} |
{ |
577 |
|
//Identifies whether or not this component can receive the focus. |
578 |
public boolean isFocusTraversable() |
return true; |
579 |
{ |
} |
580 |
//Identifies whether or not this component can receive the focus. |
|
581 |
return true; |
|
582 |
} |
protected int checkHorizontalKey(int key, String exception) |
583 |
|
{ |
584 |
|
// Verify that key is a legal value for the horizontalAlignment properties. |
585 |
protected int checkHorizontalKey(int key, String exception) |
return 0; |
586 |
{ |
} |
587 |
// Verify that key is a legal value for the horizontalAlignment properties. |
|
588 |
return 0; |
protected int checkVerticalKey(int key, String exception) |
589 |
} |
{ |
590 |
protected int checkVerticalKey(int key, String exception) |
// Ensures that the key is a valid. |
591 |
{ |
return 0; |
592 |
// Ensures that the key is a valid. |
} |
593 |
return 0; |
|
594 |
} |
protected void configurePropertiesFromAction(Action a) |
595 |
protected void configurePropertiesFromAction(Action a) |
{ |
596 |
{ |
//Factory method which sets the ActionEvent source's properties according to values from the Action instance. |
597 |
//Factory method which sets the ActionEvent source's properties according to values from the Action instance. |
} |
598 |
} |
|
599 |
|
protected ActionListener createActionListener() |
600 |
protected ActionListener createActionListener() |
{ |
601 |
{ |
return new ActionListener() |
602 |
return new ActionListener() |
{ |
603 |
{ |
public void actionPerformed(ActionEvent e) { } |
604 |
public void actionPerformed(ActionEvent e) { } |
}; |
605 |
}; |
} |
606 |
} |
|
607 |
|
protected PropertyChangeListener createActionPropertyChangeListener(Action a) |
608 |
protected PropertyChangeListener createActionPropertyChangeListener(Action a) |
{ |
609 |
{ |
//Factory method which creates the PropertyChangeListener used to update the ActionEvent source as properties change on its Action instance. |
610 |
//Factory method which creates the PropertyChangeListener used to update the ActionEvent source as properties change on its Action instance. |
return null; |
611 |
return null; |
} |
612 |
} |
|
613 |
protected ChangeListener createChangeListener() |
protected ChangeListener createChangeListener() |
614 |
{ |
{ |
615 |
// Subclasses that want to handle ChangeEvents differently can override this to return another ChangeListener implementation. |
// Subclasses that want to handle ChangeEvents differently can override this to return another ChangeListener implementation. |
616 |
return new ChangeListener() |
return new ChangeListener() |
617 |
{ |
{ |
618 |
public void stateChanged(ChangeEvent e) { } |
public void stateChanged(ChangeEvent e) { } |
619 |
}; |
}; |
620 |
} |
} |
621 |
|
|
622 |
protected ItemListener createItemListener() |
protected ItemListener createItemListener() |
623 |
{ |
{ |
624 |
return new ItemListener() |
return new ItemListener() |
625 |
{ |
{ |
626 |
public void itemStateChanged(ItemEvent e) { } |
public void itemStateChanged(ItemEvent e) { } |
627 |
}; |
}; |
628 |
} |
} |
629 |
|
|
630 |
|
public void doClick() |
631 |
public void doClick() |
{ |
632 |
{ |
doClick(100); |
633 |
doClick(100); |
} |
634 |
} |
|
635 |
public void doClick(int pressTime) |
public void doClick(int pressTime) |
636 |
{ |
{ |
637 |
//Toolkit.tlkBeep (); |
//Toolkit.tlkBeep (); |
638 |
//Programmatically perform a "click". |
//Programmatically perform a "click". |
639 |
} |
} |
640 |
|
|
641 |
|
public Icon getDisabledSelectedIcon() |
642 |
public Icon getDisabledSelectedIcon() |
{ |
643 |
{ |
//Returns the icon used by the button when it's disabled and selected. |
644 |
//Returns the icon used by the button when it's disabled and selected. |
return disabled_selected_button; |
645 |
return disabled_selected_button; |
} |
646 |
} |
|
647 |
|
public Icon getRolloverIcon() |
648 |
|
{ |
649 |
public Icon getRolloverIcon() |
// Returns the rollover icon for the button. |
650 |
{ |
return null; |
651 |
// Returns the rollover icon for the button. |
} |
652 |
return null; |
|
653 |
} |
Icon getRolloverSelectedIcon() |
654 |
|
{ |
655 |
Icon getRolloverSelectedIcon() |
// Returns the rollover selection icon for the button. |
656 |
{ |
return null; |
657 |
// Returns the rollover selection icon for the button. |
} |
658 |
return null; |
|
659 |
} |
Icon getSelectedIcon() |
660 |
Icon getSelectedIcon() |
{ |
661 |
{ |
// Returns the selected icon for the button. |
662 |
// Returns the selected icon for the button. |
return selected_button; |
663 |
return selected_button; |
} |
664 |
} |
|
665 |
|
public Object[] getSelectedObjects() |
666 |
|
{ |
667 |
public Object[] getSelectedObjects() |
//Returns an array (length 1) containing the label or null if the button is not selected. |
668 |
{ |
return null; |
669 |
//Returns an array (length 1) containing the label or null if the button is not selected. |
} |
670 |
return null; |
|
671 |
} |
public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) |
672 |
|
{ |
673 |
|
//This is overridden to return false if the current Icon's Image is not equal to the passed in Image img. |
674 |
public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) |
return current_icon == img; |
675 |
{ |
} |
676 |
//This is overridden to return false if the current Icon's Image is not equal to the passed in Image img. |
|
677 |
return current_icon == img; |
public boolean isContentAreaFilled() |
678 |
} |
{ |
679 |
|
// Checks whether the "content area" of the button should be filled. |
680 |
public boolean isContentAreaFilled() |
return false; |
681 |
{ |
} |
682 |
// Checks whether the "content area" of the button should be filled. |
|
683 |
return false; |
protected void paintBorder(Graphics g) |
684 |
} |
{ |
685 |
|
// Paint the button's border if BorderPainted property is true. |
686 |
|
if (isBorderPainted()) |
687 |
|
super.paintBorder(g); |
688 |
protected void paintBorder(Graphics g) |
} |
689 |
{ |
|
690 |
// Paint the button's border if BorderPainted property is true. |
protected String paramString() |
691 |
if (isBorderPainted()) |
{ |
692 |
super.paintBorder(g); |
// Returns a string representation of this AbstractButton. |
693 |
} |
return "AbstractButton"; |
694 |
protected String paramString() |
} |
695 |
{ |
|
696 |
// Returns a string representation of this AbstractButton. |
public void setContentAreaFilled(boolean b) |
697 |
return "AbstractButton"; |
{ |
698 |
} |
//Sets whether the button should paint the content area or leave it transparent. |
699 |
|
} |
700 |
|
|
701 |
public void setContentAreaFilled(boolean b) |
public void setDisabledSelectedIcon(Icon disabledSelectedIcon) |
702 |
{ |
{ |
703 |
//Sets whether the button should paint the content area or leave it transparent. |
// Sets the disabled selection icon for the button. |
704 |
} |
} |
705 |
|
|
706 |
|
public void setRolloverIcon(Icon rolloverIcon) |
707 |
public void setDisabledSelectedIcon(Icon disabledSelectedIcon) |
{ |
708 |
{ |
// Sets the rollover icon for the button. |
709 |
// Sets the disabled selection icon for the button. |
} |
710 |
} |
public void setRolloverSelectedIcon(Icon rolloverSelectedIcon) |
711 |
|
{ |
712 |
public void setRolloverIcon(Icon rolloverIcon) |
// Sets the rollover selected icon for the button. |
713 |
{ |
} |
714 |
// Sets the rollover icon for the button. |
|
715 |
} |
public void setSelectedIcon(Icon selectedIcon) |
716 |
public void setRolloverSelectedIcon(Icon rolloverSelectedIcon) |
{ |
717 |
{ |
// Sets the selected icon for the button. |
718 |
// Sets the rollover selected icon for the button. |
} |
719 |
} |
|
720 |
|
public void setUI(ButtonUI ui) |
721 |
|
{ // Sets the L&F object that renders this component. |
722 |
public void setSelectedIcon(Icon selectedIcon) |
super.setUI(ui); |
723 |
{ |
} |
724 |
// Sets the selected icon for the button. |
|
725 |
} |
public ButtonUI getUI() |
726 |
|
{ |
727 |
|
//Returns the L&F object that renders this component. |
728 |
public void setUI(ButtonUI ui) |
return (ButtonUI) ui; |
729 |
{ // Sets the L&F object that renders this component. |
} |
730 |
super.setUI(ui); |
|
731 |
} |
public void updateUI() |
732 |
|
{ |
733 |
public ButtonUI getUI() |
/* |
734 |
{ |
// Notification from the UIFactory that the L&F has changed. |
735 |
//Returns the L&F object that renders this component. |
if (getUI() == null) |
736 |
return (ButtonUI) ui; |
{ |
737 |
} |
setUI(getUI()); |
738 |
|
} |
739 |
public void updateUI() |
*/ |
740 |
{ |
} |
741 |
/* |
|
742 |
// Notification from the UIFactory that the L&F has changed. |
protected void processActionEvent(ActionEvent e) |
743 |
if (getUI() == null) |
{ |
744 |
{ |
System.out.println("PROCESS-ACTION-EVENT: " + e); |
745 |
setUI(getUI()); |
} |
746 |
} |
|
747 |
*/ |
protected void processMouseEvent(MouseEvent e) |
748 |
} |
{ |
749 |
|
// System.out.println("PROCESS-MOUSE-EVENT: " + e + ", PRESSED-IN-MODEL="+getModel().isPressed()); |
750 |
protected void processActionEvent(ActionEvent e) |
|
751 |
{ |
switch (e.getID()) |
752 |
System.out.println("PROCESS-ACTION-EVENT: " + e); |
{ |
753 |
} |
case MouseEvent.MOUSE_MOVED: |
754 |
|
{ |
755 |
|
break; |
756 |
protected void processMouseEvent(MouseEvent e) |
} |
757 |
{ |
case MouseEvent.MOUSE_PRESSED: |
758 |
// System.out.println("PROCESS-MOUSE-EVENT: " + e + ", PRESSED-IN-MODEL="+getModel().isPressed()); |
{ |
759 |
|
if (! isEnabled()) |
760 |
switch (e.getID()) |
{ |
761 |
{ |
System.out.println("button not enabled, ignoring press"); |
762 |
case MouseEvent.MOUSE_MOVED: |
} |
763 |
{ |
else |
764 |
break; |
{ |
765 |
} |
System.out.println("telling model:press: " + getModel()); |
766 |
case MouseEvent.MOUSE_PRESSED: |
getModel().setPressed(true); |
767 |
{ |
repaint(); |
768 |
if (! isEnabled()) |
} |
769 |
{ |
break; |
770 |
System.out.println("button not enabled, ignoring press"); |
} |
771 |
} |
|
772 |
else |
case MouseEvent.MOUSE_RELEASED: |
773 |
{ |
{ |
774 |
System.out.println("telling model:press: " + getModel()); |
if (! isEnabled()) |
775 |
getModel().setPressed(true); |
{ |
776 |
repaint(); |
System.out.println("button not enabled, ignoring release"); |
777 |
} |
} |
778 |
break; |
else |
779 |
} |
{ |
780 |
|
int flags = 0; |
781 |
case MouseEvent.MOUSE_RELEASED: |
|
782 |
{ |
System.out.println(" XXX--> " + getActionCommand()); |
783 |
if (! isEnabled()) |
|
784 |
{ |
fireActionPerformed(new ActionEvent(this, |
785 |
System.out.println("button not enabled, ignoring release"); |
ActionEvent.ACTION_PERFORMED, |
786 |
} |
getActionCommand(), |
787 |
else |
flags)); |
788 |
{ |
|
789 |
int flags = 0; |
//System.out.println("telling model:release"); |
790 |
|
getModel().setPressed(false); |
791 |
System.out.println(" XXX--> " + getActionCommand()); |
repaint(); |
792 |
|
} |
793 |
fireActionPerformed(new ActionEvent(this, |
break; |
794 |
ActionEvent.ACTION_PERFORMED, |
} |
795 |
getActionCommand(), |
case MouseEvent.MOUSE_CLICKED: |
796 |
flags)); |
{ |
797 |
|
break; |
798 |
//System.out.println("telling model:release"); |
} |
799 |
getModel().setPressed(false); |
} |
800 |
repaint(); |
} |
|
} |
|
|
break; |
|
|
} |
|
|
case MouseEvent.MOUSE_CLICKED: |
|
|
{ |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
801 |
} |
} |