01: package net.xoetrope.awt;
02:
03: import java.awt.Button;
04:
05: import net.xoetrope.xui.XValueHolder;
06: import net.xoetrope.xui.XTextHolder;
07: import net.xoetrope.xui.XAttributedComponent;
08:
09: /**
10: * <p>A wrapper for the AWT Button class. In addition to wrapping the button this
11: * object can hold a value. </p>
12: * <p>Copyright (c) Xoetrope Ltd., 1998-2003<br>
13: * License: see license.txt
14: * @version $Revision: 1.7 $
15: */
16: public class XButton extends Button implements XTextHolder,
17: XValueHolder, XAttributedComponent {
18: protected Object value;
19:
20: public XButton() {
21: }
22:
23: public void setText(String s) {
24: setLabel(s);
25: }
26:
27: public String getText() {
28: return getLabel();
29: }
30:
31: /**
32: * Set one or more attributes of the component.
33: * @param attribName the name of the attribute
34: * @param attribValue the value of the attribute
35: */
36: public void setAttribute(String attribName, String attribValue) {
37: }
38:
39: /**
40: * Get the radiobutton's value if it has one or else get the text
41: * @return the value for this button
42: */
43: public Object getValue() {
44: if (value != null)
45: return value;
46:
47: return getText();
48: }
49:
50: /**
51: * Set the value associated with this button
52: * @param newValue the new button value
53: */
54: public void setValue(Object newValue) {
55: value = newValue;
56: }
57: }
|