001: /*
002: * Copyright Javelin Software, All rights reserved.
003: */
004:
005: package com.javelin.swinglets;
006:
007: import java.awt.*;
008: import java.util.*;
009: import java.io.*;
010:
011: /**
012: * SAbstractButton defines an abstract button.
013: *
014: * @author Robin Sharp
015: */
016:
017: public class SAbstractButton extends SComponent {
018: /**
019: * Creates a SAbstractButton with the following text.
020: */
021: public SAbstractButton(String text) {
022: setText(text);
023: }
024:
025: /**
026: * Creates a SAbstractButton with the following text.
027: */
028: public SAbstractButton(String text, SIcon icon) {
029: setText(text);
030: setIcon(icon);
031: }
032:
033: /**
034: * Creates a SButton.
035: */
036: public SAbstractButton() {
037: setText("");
038: }
039:
040: /**
041: * Returns the name of the L&F class that renders this component.
042: */
043: public Class getUIClass() {
044: return SAbstractButton.class;
045: }
046:
047: /**
048: * Get the text.
049: */
050: public String getText() {
051: return text;
052: }
053:
054: /**
055: * Set the text.
056: */
057: public SAbstractButton setText(String text) {
058: firePropertyChange("text", this .text, this .text = text);
059: return this ;
060: }
061:
062: /**
063: * Check whether the button is selected.
064: */
065: public boolean isSelected() {
066: return selected;
067: }
068:
069: /**
070: * Set whether the button in selected.
071: */
072: public SAbstractButton setSelected(boolean selected) {
073: firePropertyChange("selected", this .selected,
074: this .selected = selected);
075: return this ;
076: }
077:
078: /**
079: * Returns the icon that this label displays.
080: */
081: public SIcon getIcon() {
082: return icon;
083: }
084:
085: /**
086: * Defines the icon this component will display.
087: */
088: public SAbstractButton setIcon(SIcon icon) {
089: firePropertyChange("icon", this .icon, this .icon = icon);
090: return this ;
091: }
092:
093: /**
094: * Returns the icon that this button displays when pressed.
095: */
096: public SIcon getPressedIcon() {
097: return pressedIcon;
098: }
099:
100: /**
101: * Defines the icon this button will display when pressed.
102: */
103: public SAbstractButton setPressedIcon(SIcon pressedIcon) {
104: firePropertyChange("pressedIcon", this .pressedIcon,
105: this .pressedIcon = pressedIcon);
106: this .pressedIcon = pressedIcon;
107: return this ;
108: }
109:
110: /**
111: * Returns the icon that this button displays when selected.
112: */
113: public SIcon getSelectedIcon() {
114: return selectedIcon;
115: }
116:
117: /**
118: * Defines the icon this button will display when selected.
119: */
120: public SAbstractButton setSelectedIcon(SIcon selectedIcon) {
121: firePropertyChange("selectedIcon", this .selectedIcon,
122: this .selectedIcon = selectedIcon);
123: this .selectedIcon = selectedIcon;
124: return this ;
125: }
126:
127: /**
128: * Returns the icon that this button displays when rolled over.
129: */
130: public SIcon getRolloverIcon() {
131: return rolloverIcon;
132: }
133:
134: /**
135: * Defines the icon this button will display when rolled over.
136: */
137: public SAbstractButton setRolloverIcon(SIcon rolloverIcon) {
138: firePropertyChange("rolloverIcon", this .rolloverIcon,
139: this .rolloverIcon = rolloverIcon);
140: return this ;
141: }
142:
143: /**
144: * Returns the icon that this button displays when rolled over and selected.
145: */
146: public SIcon getRolloverSelectedIcon() {
147: return rolloverSelectedIcon;
148: }
149:
150: /**
151: * Defines the icon this button will display when rolled over and selected.
152: */
153: public SAbstractButton setRolloverSelectedIcon(
154: SIcon rolloverSelectedIcon) {
155: firePropertyChange("rolloverSelectedIcon",
156: this .rolloverSelectedIcon,
157: this .rolloverSelectedIcon = rolloverSelectedIcon);
158: return this ;
159: }
160:
161: // PRIVATE /////////////////////////////////////////////////
162:
163: protected String text;
164: protected boolean selected;
165: protected SIcon icon;
166: protected SIcon pressedIcon;
167: protected SIcon selectedIcon;
168: protected SIcon rolloverIcon;
169: protected SIcon rolloverSelectedIcon;
170:
171: }
|