001: /*
002: * This file is part of the Echo Web Application Framework (hereinafter "Echo").
003: * Copyright (C) 2002-2005 NextApp, Inc.
004: *
005: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
006: *
007: * The contents of this file are subject to the Mozilla Public License Version
008: * 1.1 (the "License"); you may not use this file except in compliance with
009: * the License. You may obtain a copy of the License at
010: * http://www.mozilla.org/MPL/
011: *
012: * Software distributed under the License is distributed on an "AS IS" basis,
013: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
014: * for the specific language governing rights and limitations under the
015: * License.
016: *
017: * Alternatively, the contents of this file may be used under the terms of
018: * either the GNU General Public License Version 2 or later (the "GPL"), or
019: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
020: * in which case the provisions of the GPL or the LGPL are applicable instead
021: * of those above. If you wish to allow use of your version of this file only
022: * under the terms of either the GPL or the LGPL, and not to allow others to
023: * use your version of this file under the terms of the MPL, indicate your
024: * decision by deleting the provisions above and replace them with the notice
025: * and other provisions required by the GPL or the LGPL. If you do not delete
026: * the provisions above, a recipient may use your version of this file under
027: * the terms of any one of the MPL, the GPL or the LGPL.
028: */
029:
030: package nextapp.echo2.app.button;
031:
032: import java.util.EventListener;
033:
034: import nextapp.echo2.app.Alignment;
035: import nextapp.echo2.app.Border;
036: import nextapp.echo2.app.Color;
037: import nextapp.echo2.app.Component;
038: import nextapp.echo2.app.Extent;
039: import nextapp.echo2.app.FillImage;
040: import nextapp.echo2.app.Font;
041: import nextapp.echo2.app.ImageReference;
042: import nextapp.echo2.app.Insets;
043: import nextapp.echo2.app.event.ActionEvent;
044: import nextapp.echo2.app.event.ActionListener;
045:
046: /**
047: * An abstract base class for button components. Provides basic properties, a
048: * model, and event handling facilities.
049: */
050: public abstract class AbstractButton extends Component {
051:
052: public static final String ACTION_LISTENERS_CHANGED_PROPERTY = "actionListeners";
053: public static final String INPUT_CLICK = "input_click";
054: public static final String PROPERTY_BACKGROUND_IMAGE = "backgroundImage";
055: public static final String PROPERTY_BORDER = "border";
056: public static final String PROPERTY_DISABLED_BACKGROUND = "disabledBackground";
057: public static final String PROPERTY_DISABLED_BACKGROUND_IMAGE = "disabledBackgroundImage";
058: public static final String PROPERTY_DISABLED_BORDER = "disabledBorder";
059: public static final String PROPERTY_DISABLED_FONT = "disabledFont";
060: public static final String PROPERTY_DISABLED_FOREGROUND = "disabledForeground";
061: public static final String PROPERTY_DISABLED_ICON = "disabledIcon";
062: public static final String PROPERTY_HEIGHT = "height";
063: public static final String PROPERTY_ICON = "icon";
064: public static final String PROPERTY_ALIGNMENT = "alignment";
065: public static final String PROPERTY_ICON_TEXT_MARGIN = "iconTextMargin";
066: public static final String PROPERTY_INSETS = "insets";
067: public static final String PROPERTY_LINE_WRAP = "lineWrap";
068: public static final String PROPERTY_MODEL = "model";
069: public static final String PROPERTY_PRESSED_BACKGROUND = "pressedBackground";
070: public static final String PROPERTY_PRESSED_BACKGROUND_IMAGE = "pressedBackgroundImage";
071: public static final String PROPERTY_PRESSED_BORDER = "pressedBorder";
072: public static final String PROPERTY_PRESSED_ENABLED = "pressedEnabled";
073: public static final String PROPERTY_PRESSED_FONT = "pressedFont";
074: public static final String PROPERTY_PRESSED_FOREGROUND = "pressedForeground";
075: public static final String PROPERTY_PRESSED_ICON = "pressedIcon";
076: public static final String PROPERTY_ROLLOVER_BACKGROUND = "rolloverBackground";
077: public static final String PROPERTY_ROLLOVER_BACKGROUND_IMAGE = "rolloverBackgroundImage";
078: public static final String PROPERTY_ROLLOVER_BORDER = "rolloverBorder";
079: public static final String PROPERTY_ROLLOVER_ENABLED = "rolloverEnabled";
080: public static final String PROPERTY_ROLLOVER_FONT = "rolloverFont";
081: public static final String PROPERTY_ROLLOVER_FOREGROUND = "rolloverForeground";
082: public static final String PROPERTY_ROLLOVER_ICON = "rolloverIcon";
083: public static final String PROPERTY_TEXT = "text";
084: public static final String PROPERTY_TEXT_ALIGNMENT = "textAlignment";
085: public static final String PROPERTY_TEXT_POSITION = "textPosition";
086: public static final String PROPERTY_TOOL_TIP_TEXT = "toolTipText";
087: public static final String PROPERTY_WIDTH = "width";
088:
089: /**
090: * Forwards events generated by the model to listeners registered with the
091: * component instance.
092: */
093: private ActionListener actionForwarder = new ActionListener() {
094:
095: /**
096: * @see nextapp.echo2.app.event.ActionListener#actionPerformed(nextapp.echo2.app.event.ActionEvent)
097: */
098: public void actionPerformed(ActionEvent modelEvent) {
099: ActionEvent buttonEvent = new ActionEvent(
100: AbstractButton.this , modelEvent.getActionCommand());
101: fireActionPerformed(buttonEvent);
102: }
103: };
104:
105: /**
106: * Adds an <code>ActionListener</code> to receive notification of user
107: * actions, i.e., button presses.
108: *
109: * @param l the listener to add
110: */
111: public void addActionListener(ActionListener l) {
112: getEventListenerList().addListener(ActionListener.class, l);
113: // Notification of action listener changes is provided due to
114: // existence of hasActionListeners() method.
115: firePropertyChange(ACTION_LISTENERS_CHANGED_PROPERTY, null, l);
116: }
117:
118: /**
119: * Programmatically performs a click/activation of the button.
120: */
121: public void doAction() {
122: getModel().doAction();
123: }
124:
125: /**
126: * Notifies all listeners that have registered for this event type.
127: *
128: * @param e the <code>ActionEvent</code> to send
129: */
130: public void fireActionPerformed(ActionEvent e) {
131: if (!hasEventListenerList()) {
132: return;
133: }
134: EventListener[] listeners = getEventListenerList()
135: .getListeners(ActionListener.class);
136: for (int index = 0; index < listeners.length; ++index) {
137: ((ActionListener) listeners[index]).actionPerformed(e);
138: }
139: }
140:
141: /**
142: * Retrieves the action command from the <code>ButtonModel</code>.
143: *
144: * @return the action command
145: * @see nextapp.echo2.app.button.ButtonModel#getActionCommand()
146: */
147: public String getActionCommand() {
148: return getModel().getActionCommand();
149: }
150:
151: /**
152: * Returns the alignment of the button's content.
153: * Only horizontal alignments are supported.
154: *
155: * @return the alignment
156: */
157: public Alignment getAlignment() {
158: return (Alignment) getProperty(PROPERTY_ALIGNMENT);
159: }
160:
161: /**
162: * Returns the background image of the button.
163: *
164: * @return the background image
165: */
166: public FillImage getBackgroundImage() {
167: return (FillImage) getProperty(PROPERTY_BACKGROUND_IMAGE);
168: }
169:
170: /**
171: * Returns the border displayed around the button.
172: *
173: * @return the border
174: */
175: public Border getBorder() {
176: return (Border) getProperty(PROPERTY_BORDER);
177: }
178:
179: /**
180: * Returns the background color of the button when the button is disabled.
181: *
182: * @return the color
183: */
184: public Color getDisabledBackground() {
185: return (Color) getProperty(PROPERTY_DISABLED_BACKGROUND);
186: }
187:
188: /**
189: * Returns the background image displayed when the button is disabled.
190: *
191: * @return the background image
192: */
193: public FillImage getDisabledBackgroundImage() {
194: return (FillImage) getProperty(PROPERTY_DISABLED_BACKGROUND_IMAGE);
195: }
196:
197: /**
198: * Returns the border displayed around the button when the button is
199: * disabled.
200: *
201: * @return the border
202: */
203: public Border getDisabledBorder() {
204: return (Border) getProperty(PROPERTY_DISABLED_BORDER);
205: }
206:
207: /**
208: * Returns the font of the button when the button is disabled.
209: *
210: * @return the font
211: */
212: public Font getDisabledFont() {
213: return (Font) getProperty(PROPERTY_DISABLED_FONT);
214: }
215:
216: /**
217: * Returns the foreground color of the button when the button is disabled.
218: *
219: * @return the color
220: */
221: public Color getDisabledForeground() {
222: return (Color) getProperty(PROPERTY_DISABLED_FOREGROUND);
223: }
224:
225: /**
226: * Returns the icon of the button that is displayed when the button is
227: * disabled.
228: *
229: * @return the icon
230: */
231: public ImageReference getDisabledIcon() {
232: return (ImageReference) getProperty(PROPERTY_DISABLED_ICON);
233: }
234:
235: /**
236: * Returns the height of the button.
237: * This property only supports <code>Extent</code>s with
238: * fixed (i.e., not percent) units.
239: *
240: * @return the height
241: */
242: public Extent getHeight() {
243: return (Extent) getProperty(PROPERTY_HEIGHT);
244: }
245:
246: /**
247: * Returns the icon displayed in the button.
248: *
249: * @return the icon
250: */
251: public ImageReference getIcon() {
252: return (ImageReference) getProperty(PROPERTY_ICON);
253: }
254:
255: /**
256: * Returns the margin size between the icon and the text.
257: * The margin will only be displayed if the button has both
258: * icon and text properties set.
259: * This property only supports <code>Extent</code>s with
260: * fixed (i.e., not percent) units.
261: *
262: * @return the margin size
263: */
264: public Extent getIconTextMargin() {
265: return (Extent) getProperty(PROPERTY_ICON_TEXT_MARGIN);
266: }
267:
268: /**
269: * Returns the margin between the buttons edge and its content.
270: *
271: * @return the margin
272: */
273: public Insets getInsets() {
274: return (Insets) getProperty(PROPERTY_INSETS);
275: }
276:
277: /**
278: * Returns the model that this button represents.
279: *
280: * @return the model
281: */
282: public ButtonModel getModel() {
283: return (ButtonModel) getProperty(PROPERTY_MODEL);
284: }
285:
286: /**
287: * Returns the background color of the button when the button is pressed.
288: *
289: * @return the color
290: */
291: public Color getPressedBackground() {
292: return (Color) getProperty(PROPERTY_PRESSED_BACKGROUND);
293: }
294:
295: /**
296: * Returns the background image displayed when the button is pressed.
297: *
298: * @return the background image
299: */
300: public FillImage getPressedBackgroundImage() {
301: return (FillImage) getProperty(PROPERTY_PRESSED_BACKGROUND_IMAGE);
302: }
303:
304: /**
305: * Returns the border displayed around the button when the button is
306: * pressed.
307: *
308: * @return the border
309: */
310: public Border getPressedBorder() {
311: return (Border) getProperty(PROPERTY_PRESSED_BORDER);
312: }
313:
314: /**
315: * Returns the font of the button when the button is pressed.
316: *
317: * @return the font
318: */
319: public Font getPressedFont() {
320: return (Font) getProperty(PROPERTY_PRESSED_FONT);
321: }
322:
323: /**
324: * Returns the foreground color of the button when the button is pressed.
325: *
326: * @return the color
327: */
328: public Color getPressedForeground() {
329: return (Color) getProperty(PROPERTY_PRESSED_FOREGROUND);
330: }
331:
332: /**
333: * Returns the icon of the button that is displayed when the button is
334: * pressed.
335: *
336: * @return the icon
337: */
338: public ImageReference getPressedIcon() {
339: return (ImageReference) getProperty(PROPERTY_PRESSED_ICON);
340: }
341:
342: /**
343: * Returns the background color of the button when the mouse cursor is
344: * inside its bounds.
345: *
346: * @return the color
347: */
348: public Color getRolloverBackground() {
349: return (Color) getProperty(PROPERTY_ROLLOVER_BACKGROUND);
350: }
351:
352: /**
353: * Returns the background image displayed when the mouse cursor is inside
354: * the button's bounds.
355: *
356: * @return the background image
357: */
358: public FillImage getRolloverBackgroundImage() {
359: return (FillImage) getProperty(PROPERTY_ROLLOVER_BACKGROUND_IMAGE);
360: }
361:
362: /**
363: * Returns the border displayed around the button when the mouse cursor is
364: * inside its bounds.
365: *
366: * @return the border
367: */
368: public Border getRolloverBorder() {
369: return (Border) getProperty(PROPERTY_ROLLOVER_BORDER);
370: }
371:
372: /**
373: * Returns the font of the button when the mouse cursor is inside its
374: * bounds.
375: *
376: * @return the font
377: */
378: public Font getRolloverFont() {
379: return (Font) getProperty(PROPERTY_ROLLOVER_FONT);
380: }
381:
382: /**
383: * Returns the foreground color of the button when the mouse cursor is
384: * inside its bounds.
385: *
386: * @return the color
387: */
388: public Color getRolloverForeground() {
389: return (Color) getProperty(PROPERTY_ROLLOVER_FOREGROUND);
390: }
391:
392: /**
393: * Returns the icon of the button that is displayed when the mouse cursor is
394: * inside its bounds.
395: *
396: * @return the icon
397: */
398: public ImageReference getRolloverIcon() {
399: return (ImageReference) getProperty(PROPERTY_ROLLOVER_ICON);
400: }
401:
402: /**
403: * Returns the text label of the button.
404: *
405: * @return the text label
406: */
407: public String getText() {
408: return (String) getProperty(PROPERTY_TEXT);
409: }
410:
411: /**
412: * Returns the alignment of the text relative to the icon.
413: *
414: * @return the text alignment
415: */
416: public Alignment getTextAlignment() {
417: return (Alignment) getProperty(PROPERTY_TEXT_ALIGNMENT);
418: }
419:
420: /**
421: * Returns the position of the text relative to the icon.
422: *
423: * @return the text position
424: */
425: public Alignment getTextPosition() {
426: return (Alignment) getProperty(PROPERTY_TEXT_POSITION);
427: }
428:
429: /**
430: * Returns the tool tip text (displayed when the mouse cursor is hovered
431: * over the component).
432: *
433: * @return the tool tip text
434: */
435: public String getToolTipText() {
436: return (String) getProperty(PROPERTY_TOOL_TIP_TEXT);
437: }
438:
439: /**
440: * Returns the width of the button.
441: * This property supports <code>Extent</code>s with
442: * fixed or percentile units.
443: *
444: * @return the width
445: */
446: public Extent getWidth() {
447: return (Extent) getProperty(PROPERTY_WIDTH);
448: }
449:
450: /**
451: * Determines if the button has any <code>ActionListener</code>s
452: * registered.
453: *
454: * @return true if any action listeners are registered
455: */
456: public boolean hasActionListeners() {
457: return hasEventListenerList()
458: && getEventListenerList().getListenerCount(
459: ActionListener.class) != 0;
460: }
461:
462: /**
463: * Determines if the text of the button should wrap in the event that
464: * horizontal space is limited. Default value is true.
465: *
466: * @return the line wrap state
467: */
468: public boolean isLineWrap() {
469: Boolean value = (Boolean) getProperty(PROPERTY_LINE_WRAP);
470: return value == null ? true : value.booleanValue();
471: }
472:
473: /**
474: * Determines if pressed effects are enabled.
475: *
476: * @return true if pressed effects are enabled
477: * @see #setPressedEnabled(boolean)
478: */
479: public boolean isPressedEnabled() {
480: Boolean value = (Boolean) getProperty(PROPERTY_PRESSED_ENABLED);
481: return value == null ? false : value.booleanValue();
482: }
483:
484: /**
485: * Determines if rollover effects are enabled.
486: *
487: * @return true if rollover effects are enabled
488: * @see #setRolloverEnabled(boolean)
489: */
490: public boolean isRolloverEnabled() {
491: Boolean value = (Boolean) getProperty(PROPERTY_ROLLOVER_ENABLED);
492: return value == null ? false : value.booleanValue();
493: }
494:
495: /**
496: * This component does not support children.
497: *
498: * @see nextapp.echo2.app.Component#isValidChild(nextapp.echo2.app.Component)
499: */
500: public boolean isValidChild(Component component) {
501: return false;
502: }
503:
504: /**
505: * @see nextapp.echo2.app.Component#processInput(java.lang.String, java.lang.Object)
506: */
507: public void processInput(String name, Object value) {
508: super .processInput(name, value);
509: if (INPUT_CLICK.equals(name)) {
510: doAction();
511: }
512: }
513:
514: /**
515: * Removes an <code>ActionListener</code> from being notified of user
516: * actions, i.e., button presses.
517: *
518: * @param l the listener to remove
519: */
520: public void removeActionListener(ActionListener l) {
521: if (!hasEventListenerList()) {
522: return;
523: }
524: getEventListenerList().removeListener(ActionListener.class, l);
525: // Notification of action listener changes is provided due to
526: // existence of hasActionListeners() method.
527: firePropertyChange(ACTION_LISTENERS_CHANGED_PROPERTY, l, null);
528: }
529:
530: /**
531: * Sets the action command of the <code>ButtonModel</code>.
532: *
533: * @param newValue the action command
534: * @see nextapp.echo2.app.button.ButtonModel#setActionCommand(java.lang.String)
535: */
536: public void setActionCommand(String newValue) {
537: getModel().setActionCommand(newValue);
538: }
539:
540: /**
541: * Sets the alignment of the button's content.
542: * Only horizontal alignments are supported.
543: *
544: * @param newValue the new alignment
545: */
546: public void setAlignment(Alignment newValue) {
547: setProperty(PROPERTY_ALIGNMENT, newValue);
548: }
549:
550: /**
551: * Sets the background image of the button.
552: *
553: * @param newValue the new background image
554: */
555: public void setBackgroundImage(FillImage newValue) {
556: setProperty(PROPERTY_BACKGROUND_IMAGE, newValue);
557: }
558:
559: /**
560: * Sets the border displayed around the button.
561: *
562: * @param newValue the new border
563: */
564: public void setBorder(Border newValue) {
565: setProperty(PROPERTY_BORDER, newValue);
566: }
567:
568: /**
569: * Sets the background color of the button when the button is disabled.
570: *
571: * @param newValue the new <code>Color</code>
572: */
573: public void setDisabledBackground(Color newValue) {
574: setProperty(PROPERTY_DISABLED_BACKGROUND, newValue);
575: }
576:
577: /**
578: * Sets the background image displayed when the button is disabled.
579: *
580: * @param newValue the new background image
581: */
582: public void setDisabledBackgroundImage(FillImage newValue) {
583: setProperty(PROPERTY_DISABLED_BACKGROUND_IMAGE, newValue);
584: }
585:
586: /**
587: * Sets the border displayed around the button when the button is disabled.
588: *
589: * @param newValue the new border
590: */
591: public void setDisabledBorder(Border newValue) {
592: setProperty(PROPERTY_DISABLED_BORDER, newValue);
593: }
594:
595: /**
596: * Sets the font of the button when the button is disabled.
597: *
598: * @param newValue the new <code>Font</code>
599: */
600: public void setDisabledFont(Font newValue) {
601: setProperty(PROPERTY_DISABLED_FONT, newValue);
602: }
603:
604: /**
605: * Sets the foreground color of the button when the button is disabled.
606: *
607: * @param newValue the new <code>Color</code>
608: */
609: public void setDisabledForeground(Color newValue) {
610: setProperty(PROPERTY_DISABLED_FOREGROUND, newValue);
611: }
612:
613: /**
614: * Sets the icon of the button that is displayed when the button is
615: * disabled.
616: *
617: * @param newValue the new icon
618: */
619: public void setDisabledIcon(ImageReference newValue) {
620: setProperty(PROPERTY_DISABLED_ICON, newValue);
621: }
622:
623: /**
624: * Sets the height of the button.
625: * This property only supports <code>Extent</code>s with
626: * fixed (i.e., not percent) units.
627: *
628: * @param newValue the new height
629: */
630: public void setHeight(Extent newValue) {
631: setProperty(PROPERTY_HEIGHT, newValue);
632: }
633:
634: /**
635: * Sets the icon displayed in the button.
636: *
637: * @param newValue the new icon
638: */
639: public void setIcon(ImageReference newValue) {
640: setProperty(PROPERTY_ICON, newValue);
641: }
642:
643: /**
644: * Sets the margin size between the icon and the text.
645: * The margin will only be displayed if the button has both
646: * icon and text properties set.
647: * This property only supports <code>Extent</code>s with
648: * fixed (i.e., not percent) units.
649: *
650: * @param newValue the margin size
651: */
652: public void setIconTextMargin(Extent newValue) {
653: setProperty(PROPERTY_ICON_TEXT_MARGIN, newValue);
654: }
655:
656: /**
657: * Sets the margin between the buttons edge and its content.
658: *
659: * @param newValue the new margin
660: */
661: public void setInsets(Insets newValue) {
662: setProperty(PROPERTY_INSETS, newValue);
663: }
664:
665: /**
666: * Sets whether the text of the button should wrap in the event that
667: * horizontal space is limited. Default value is true.
668: *
669: * @param newValue the new line wrap state
670: */
671: public void setLineWrap(boolean newValue) {
672: setProperty(PROPERTY_LINE_WRAP, new Boolean(newValue));
673: }
674:
675: /**
676: * Sets the model that this button represents. The model may not be null.
677: *
678: * @param newValue the new <code>ButtonModel</code>
679: */
680: public void setModel(ButtonModel newValue) {
681: if (newValue == null) {
682: throw new IllegalArgumentException("Model may not be null.");
683: }
684:
685: ButtonModel oldValue = getModel();
686:
687: if (oldValue != null) {
688: oldValue.removeActionListener(actionForwarder);
689: }
690:
691: newValue.addActionListener(actionForwarder);
692:
693: setProperty(PROPERTY_MODEL, newValue);
694: }
695:
696: /**
697: * Sets the background color of the button when the button is pressed.
698: *
699: * @param newValue the new <code>Color</code>
700: */
701: public void setPressedBackground(Color newValue) {
702: setProperty(PROPERTY_PRESSED_BACKGROUND, newValue);
703: }
704:
705: /**
706: * Sets the background image displayed when the button is pressed.
707: *
708: * @param newValue the new background image
709: */
710: public void setPressedBackgroundImage(FillImage newValue) {
711: setProperty(PROPERTY_PRESSED_BACKGROUND_IMAGE, newValue);
712: }
713:
714: /**
715: * Sets the border displayed around the button when the button is pressed.
716: *
717: * @param newValue the new border
718: */
719: public void setPressedBorder(Border newValue) {
720: setProperty(PROPERTY_PRESSED_BORDER, newValue);
721: }
722:
723: /**
724: * Sets whether pressed effects are enabled when the button is pressed.
725: * Pressed properties have no effect unless this property is set to true.
726: * The default value is false.
727: *
728: * @param newValue true if pressed effects should be enabled
729: */
730: public void setPressedEnabled(boolean newValue) {
731: setProperty(PROPERTY_PRESSED_ENABLED, new Boolean(newValue));
732: }
733:
734: /**
735: * Sets the font of the button when the button is pressed.
736: *
737: * @param newValue the new <code>Font</code>
738: */
739: public void setPressedFont(Font newValue) {
740: setProperty(PROPERTY_PRESSED_FONT, newValue);
741: }
742:
743: /**
744: * Sets the foreground color of the button when the button is pressed.
745: *
746: * @param newValue the new <code>Color</code>
747: */
748: public void setPressedForeground(Color newValue) {
749: setProperty(PROPERTY_PRESSED_FOREGROUND, newValue);
750: }
751:
752: /**
753: * Sets the icon of the button that is displayed when the button is pressed.
754: *
755: * @param newValue the new icon
756: */
757: public void setPressedIcon(ImageReference newValue) {
758: setProperty(PROPERTY_PRESSED_ICON, newValue);
759: }
760:
761: /**
762: * Sets the background color of the button when the mouse cursor is inside
763: * its bounds.
764: *
765: * @param newValue the new <code>Color</code>
766: */
767: public void setRolloverBackground(Color newValue) {
768: setProperty(PROPERTY_ROLLOVER_BACKGROUND, newValue);
769: }
770:
771: /**
772: * Sets the background image displayed when the mouse cursor is inside the
773: * button's bounds
774: *
775: * @param newValue the new background image
776: */
777: public void setRolloverBackgroundImage(FillImage newValue) {
778: setProperty(PROPERTY_ROLLOVER_BACKGROUND_IMAGE, newValue);
779: }
780:
781: /**
782: * Sets the border displayed around the button when the mouse cursor is
783: * inside its bounds.
784: *
785: * @param newValue the new border
786: */
787: public void setRolloverBorder(Border newValue) {
788: setProperty(PROPERTY_ROLLOVER_BORDER, newValue);
789: }
790:
791: /**
792: * Sets whether rollover effects are enabled when the mouse cursor is inside
793: * the button's bounds. Rollover properties have no effect unless this
794: * property is set to true. The default value is false.
795: *
796: * @param newValue true if rollover effects should be enabled
797: */
798: public void setRolloverEnabled(boolean newValue) {
799: setProperty(PROPERTY_ROLLOVER_ENABLED, new Boolean(newValue));
800: }
801:
802: /**
803: * Sets the font of the button when the mouse cursor is inside its bounds.
804: *
805: * @param newValue the new <code>Font</code>
806: */
807: public void setRolloverFont(Font newValue) {
808: setProperty(PROPERTY_ROLLOVER_FONT, newValue);
809: }
810:
811: /**
812: * Sets the foreground color of the button when the mouse cursor is inside
813: * its bounds.
814: *
815: * @param newValue the new <code>Color</code>
816: */
817: public void setRolloverForeground(Color newValue) {
818: setProperty(PROPERTY_ROLLOVER_FOREGROUND, newValue);
819: }
820:
821: /**
822: * Sets the icon of the button that is displayed when the mouse cursor is
823: * inside its bounds.
824: *
825: * @param newValue the new icon
826: */
827: public void setRolloverIcon(ImageReference newValue) {
828: setProperty(PROPERTY_ROLLOVER_ICON, newValue);
829: }
830:
831: /**
832: * Sets the text label of the button.
833: *
834: * @param newValue the new text label
835: */
836: public void setText(String newValue) {
837: setProperty(PROPERTY_TEXT, newValue);
838: }
839:
840: /**
841: * Sets the alignment of the text relative to the icon.
842: * Note that only one of the provided <code>Alignment</code>'s
843: * settings should be non-default.
844: *
845: * @param newValue the new text alignment
846: */
847: public void setTextAlignment(Alignment newValue) {
848: setProperty(PROPERTY_TEXT_ALIGNMENT, newValue);
849: }
850:
851: /**
852: * Sets the position of the text relative to the icon.
853: * Note that only one of the provided <code>Alignment</code>'s
854: * settings should be non-default.
855: *
856: * @param newValue the new text position
857: */
858: public void setTextPosition(Alignment newValue) {
859: setProperty(PROPERTY_TEXT_POSITION, newValue);
860: }
861:
862: /**
863: * Sets the tool tip text (displayed when the mouse cursor is hovered
864: * over the component).
865: *
866: * @param newValue the new tool tip text
867: */
868: public void setToolTipText(String newValue) {
869: setProperty(PROPERTY_TOOL_TIP_TEXT, newValue);
870: }
871:
872: /**
873: * Sets the width of the button.
874: * This property supports <code>Extent</code>s with
875: * fixed or percentile units.
876: *
877: * @param newValue the new width
878: */
879: public void setWidth(Extent newValue) {
880: setProperty(PROPERTY_WIDTH, newValue);
881: }
882: }
|