KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nextapp > echo2 > app > button > AbstractButton


1 /*
2  * This file is part of the Echo Web Application Framework (hereinafter "Echo").
3  * Copyright (C) 2002-2005 NextApp, Inc.
4  *
5  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * Alternatively, the contents of this file may be used under the terms of
18  * either the GNU General Public License Version 2 or later (the "GPL"), or
19  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20  * in which case the provisions of the GPL or the LGPL are applicable instead
21  * of those above. If you wish to allow use of your version of this file only
22  * under the terms of either the GPL or the LGPL, and not to allow others to
23  * use your version of this file under the terms of the MPL, indicate your
24  * decision by deleting the provisions above and replace them with the notice
25  * and other provisions required by the GPL or the LGPL. If you do not delete
26  * the provisions above, a recipient may use your version of this file under
27  * the terms of any one of the MPL, the GPL or the LGPL.
28  */

29
30 package nextapp.echo2.app.button;
31
32 import java.util.EventListener JavaDoc;
33
34 import nextapp.echo2.app.Alignment;
35 import nextapp.echo2.app.Border;
36 import nextapp.echo2.app.Color;
37 import nextapp.echo2.app.Component;
38 import nextapp.echo2.app.Extent;
39 import nextapp.echo2.app.FillImage;
40 import nextapp.echo2.app.Font;
41 import nextapp.echo2.app.ImageReference;
42 import nextapp.echo2.app.Insets;
43 import nextapp.echo2.app.event.ActionEvent;
44 import nextapp.echo2.app.event.ActionListener;
45
46 /**
47  * An abstract base class for button components. Provides basic properties, a
48  * model, and event handling facilities.
49  */

50 public abstract class AbstractButton extends Component {
51     
52     public static final String JavaDoc ACTION_LISTENERS_CHANGED_PROPERTY = "actionListeners";
53     public static final String JavaDoc INPUT_CLICK = "input_click";
54     public static final String JavaDoc PROPERTY_BACKGROUND_IMAGE = "backgroundImage";
55     public static final String JavaDoc PROPERTY_BORDER = "border";
56     public static final String JavaDoc PROPERTY_DISABLED_BACKGROUND = "disabledBackground";
57     public static final String JavaDoc PROPERTY_DISABLED_BACKGROUND_IMAGE = "disabledBackgroundImage";
58     public static final String JavaDoc PROPERTY_DISABLED_BORDER = "disabledBorder";
59     public static final String JavaDoc PROPERTY_DISABLED_FONT = "disabledFont";
60     public static final String JavaDoc PROPERTY_DISABLED_FOREGROUND = "disabledForeground";
61     public static final String JavaDoc PROPERTY_DISABLED_ICON = "disabledIcon";
62     public static final String JavaDoc PROPERTY_HEIGHT = "height";
63     public static final String JavaDoc PROPERTY_ICON = "icon";
64     public static final String JavaDoc PROPERTY_ALIGNMENT = "alignment";
65     public static final String JavaDoc PROPERTY_ICON_TEXT_MARGIN = "iconTextMargin";
66     public static final String JavaDoc PROPERTY_INSETS = "insets";
67     public static final String JavaDoc PROPERTY_LINE_WRAP = "lineWrap";
68     public static final String JavaDoc PROPERTY_MODEL = "model";
69     public static final String JavaDoc PROPERTY_PRESSED_BACKGROUND = "pressedBackground";
70     public static final String JavaDoc PROPERTY_PRESSED_BACKGROUND_IMAGE = "pressedBackgroundImage";
71     public static final String JavaDoc PROPERTY_PRESSED_BORDER = "pressedBorder";
72     public static final String JavaDoc PROPERTY_PRESSED_ENABLED = "pressedEnabled";
73     public static final String JavaDoc PROPERTY_PRESSED_FONT = "pressedFont";
74     public static final String JavaDoc PROPERTY_PRESSED_FOREGROUND = "pressedForeground";
75     public static final String JavaDoc PROPERTY_PRESSED_ICON = "pressedIcon";
76     public static final String JavaDoc PROPERTY_ROLLOVER_BACKGROUND = "rolloverBackground";
77     public static final String JavaDoc PROPERTY_ROLLOVER_BACKGROUND_IMAGE = "rolloverBackgroundImage";
78     public static final String JavaDoc PROPERTY_ROLLOVER_BORDER = "rolloverBorder";
79     public static final String JavaDoc PROPERTY_ROLLOVER_ENABLED = "rolloverEnabled";
80     public static final String JavaDoc PROPERTY_ROLLOVER_FONT = "rolloverFont";
81     public static final String JavaDoc PROPERTY_ROLLOVER_FOREGROUND = "rolloverForeground";
82     public static final String JavaDoc PROPERTY_ROLLOVER_ICON = "rolloverIcon";
83     public static final String JavaDoc PROPERTY_TEXT = "text";
84     public static final String JavaDoc PROPERTY_TEXT_ALIGNMENT = "textAlignment";
85     public static final String JavaDoc PROPERTY_TEXT_POSITION = "textPosition";
86     public static final String JavaDoc PROPERTY_TOOL_TIP_TEXT = "toolTipText";
87     public static final String JavaDoc PROPERTY_WIDTH = "width";
88
89     /**
90      * Forwards events generated by the model to listeners registered with the
91      * component instance.
92      */

93     private ActionListener actionForwarder = new ActionListener() {
94
95         /**
96          * @see nextapp.echo2.app.event.ActionListener#actionPerformed(nextapp.echo2.app.event.ActionEvent)
97          */

98         public void actionPerformed(ActionEvent modelEvent) {
99             ActionEvent buttonEvent = new ActionEvent(AbstractButton.this, modelEvent.getActionCommand());
100             fireActionPerformed(buttonEvent);
101         }
102     };
103     
104     /**
105      * Adds an <code>ActionListener</code> to receive notification of user
106      * actions, i.e., button presses.
107      *
108      * @param l the listener to add
109      */

110     public void addActionListener(ActionListener l) {
111         getEventListenerList().addListener(ActionListener.class, l);
112         // Notification of action listener changes is provided due to
113
// existence of hasActionListeners() method.
114
firePropertyChange(ACTION_LISTENERS_CHANGED_PROPERTY, null, l);
115     }
116
117     /**
118      * Programmatically performs a click/activation of the button.
119      */

120     public void doAction() {
121         getModel().doAction();
122     }
123
124     /**
125      * Notifies all listeners that have registered for this event type.
126      *
127      * @param e the <code>ActionEvent</code> to send
128      */

129     public void fireActionPerformed(ActionEvent e) {
130         if (!hasEventListenerList()) {
131             return;
132         }
133         EventListener JavaDoc[] listeners = getEventListenerList().getListeners(ActionListener.class);
134         for (int index = 0; index < listeners.length; ++index) {
135             ((ActionListener) listeners[index]).actionPerformed(e);
136         }
137     }
138
139     /**
140      * Retrieves the action command from the <code>ButtonModel</code>.
141      *
142      * @return the action command
143      * @see nextapp.echo2.app.button.ButtonModel#getActionCommand()
144      */

145     public String JavaDoc getActionCommand() {
146         return getModel().getActionCommand();
147     }
148     
149     /**
150      * Returns the alignment of the button's content.
151      * Only horizontal alignments are supported.
152      *
153      * @return the alignment
154      */

155     public Alignment getAlignment() {
156         return (Alignment) getProperty(PROPERTY_ALIGNMENT);
157     }
158
159     /**
160      * Returns the background image of the button.
161      *
162      * @return the background image
163      */

164     public FillImage getBackgroundImage() {
165         return (FillImage) getProperty(PROPERTY_BACKGROUND_IMAGE);
166     }
167
168     /**
169      * Returns the border displayed around the button.
170      *
171      * @return the border
172      */

173     public Border getBorder() {
174         return (Border) getProperty(PROPERTY_BORDER);
175     }
176     
177     /**
178      * Returns the background color of the button when the button is disabled.
179      *
180      * @return the color
181      */

182     public Color getDisabledBackground() {
183         return (Color) getProperty(PROPERTY_DISABLED_BACKGROUND);
184     }
185
186     /**
187      * Returns the background image displayed when the button is disabled.
188      *
189      * @return the background image
190      */

191     public FillImage getDisabledBackgroundImage() {
192         return (FillImage) getProperty(PROPERTY_DISABLED_BACKGROUND_IMAGE);
193     }
194
195     /**
196      * Returns the border displayed around the button when the button is
197      * disabled.
198      *
199      * @return the border
200      */

201     public Border getDisabledBorder() {
202         return (Border) getProperty(PROPERTY_DISABLED_BORDER);
203     }
204
205     /**
206      * Returns the font of the button when the button is disabled.
207      *
208      * @return the font
209      */

210     public Font getDisabledFont() {
211         return (Font) getProperty(PROPERTY_DISABLED_FONT);
212     }
213
214     /**
215      * Returns the foreground color of the button when the button is disabled.
216      *
217      * @return the color
218      */

219     public Color getDisabledForeground() {
220         return (Color) getProperty(PROPERTY_DISABLED_FOREGROUND);
221     }
222
223     /**
224      * Returns the icon of the button that is displayed when the button is
225      * disabled.
226      *
227      * @return the icon
228      */

229     public ImageReference getDisabledIcon() {
230         return (ImageReference) getProperty(PROPERTY_DISABLED_ICON);
231     }
232
233     /**
234      * Returns the height of the button.
235      * This property only supports <code>Extent</code>s with
236      * fixed (i.e., not percent) units.
237      *
238      * @return the height
239      */

240     public Extent getHeight() {
241         return (Extent) getProperty(PROPERTY_HEIGHT);
242     }
243
244     /**
245      * Returns the icon displayed in the button.
246      *
247      * @return the icon
248      */

249     public ImageReference getIcon() {
250         return (ImageReference) getProperty(PROPERTY_ICON);
251     }
252
253     /**
254      * Returns the margin size between the icon and the text.
255      * The margin will only be displayed if the button has both
256      * icon and text properties set.
257      * This property only supports <code>Extent</code>s with
258      * fixed (i.e., not percent) units.
259      *
260      * @return the margin size
261      */

262     public Extent getIconTextMargin() {
263         return (Extent) getProperty(PROPERTY_ICON_TEXT_MARGIN);
264     }
265     
266     /**
267      * Returns the margin between the buttons edge and its content.
268      *
269      * @return the margin
270      */

271     public Insets getInsets() {
272         return (Insets) getProperty(PROPERTY_INSETS);
273     }
274
275     /**
276      * Returns the model that this button represents.
277      *
278      * @return the model
279      */

280     public ButtonModel getModel() {
281         return (ButtonModel) getProperty(PROPERTY_MODEL);
282     }
283
284     /**
285      * Returns the background color of the button when the button is pressed.
286      *
287      * @return the color
288      */

289     public Color getPressedBackground() {
290         return (Color) getProperty(PROPERTY_PRESSED_BACKGROUND);
291     }
292
293     /**
294      * Returns the background image displayed when the button is pressed.
295      *
296      * @return the background image
297      */

298     public FillImage getPressedBackgroundImage() {
299         return (FillImage) getProperty(PROPERTY_PRESSED_BACKGROUND_IMAGE);
300     }
301
302     /**
303      * Returns the border displayed around the button when the button is
304      * pressed.
305      *
306      * @return the border
307      */

308     public Border getPressedBorder() {
309         return (Border) getProperty(PROPERTY_PRESSED_BORDER);
310     }
311
312     /**
313      * Returns the font of the button when the button is pressed.
314      *
315      * @return the font
316      */

317     public Font getPressedFont() {
318         return (Font) getProperty(PROPERTY_PRESSED_FONT);
319     }
320
321     /**
322      * Returns the foreground color of the button when the button is pressed.
323      *
324      * @return the color
325      */

326     public Color getPressedForeground() {
327         return (Color) getProperty(PROPERTY_PRESSED_FOREGROUND);
328     }
329
330     /**
331      * Returns the icon of the button that is displayed when the button is
332      * pressed.
333      *
334      * @return the icon
335      */

336     public ImageReference getPressedIcon() {
337         return (ImageReference) getProperty(PROPERTY_PRESSED_ICON);
338     }
339
340     /**
341      * Returns the background color of the button when the mouse cursor is
342      * inside its bounds.
343      *
344      * @return the color
345      */

346     public Color getRolloverBackground() {
347         return (Color) getProperty(PROPERTY_ROLLOVER_BACKGROUND);
348     }
349
350     /**
351      * Returns the background image displayed when the mouse cursor is inside
352      * the button's bounds.
353      *
354      * @return the background image
355      */

356     public FillImage getRolloverBackgroundImage() {
357         return (FillImage) getProperty(PROPERTY_ROLLOVER_BACKGROUND_IMAGE);
358     }
359
360     /**
361      * Returns the border displayed around the button when the mouse cursor is
362      * inside its bounds.
363      *
364      * @return the border
365      */

366     public Border getRolloverBorder() {
367         return (Border) getProperty(PROPERTY_ROLLOVER_BORDER);
368     }
369
370     /**
371      * Returns the font of the button when the mouse cursor is inside its
372      * bounds.
373      *
374      * @return the font
375      */

376     public Font getRolloverFont() {
377         return (Font) getProperty(PROPERTY_ROLLOVER_FONT);
378     }
379
380     /**
381      * Returns the foreground color of the button when the mouse cursor is
382      * inside its bounds.
383      *
384      * @return the color
385      */

386     public Color getRolloverForeground() {
387         return (Color) getProperty(PROPERTY_ROLLOVER_FOREGROUND);
388     }
389
390     /**
391      * Returns the icon of the button that is displayed when the mouse cursor is
392      * inside its bounds.
393      *
394      * @return the icon
395      */

396     public ImageReference getRolloverIcon() {
397         return (ImageReference) getProperty(PROPERTY_ROLLOVER_ICON);
398     }
399
400     /**
401      * Returns the text label of the button.
402      *
403      * @return the text label
404      */

405     public String JavaDoc getText() {
406         return (String JavaDoc) getProperty(PROPERTY_TEXT);
407     }
408
409     /**
410      * Returns the alignment of the text relative to the icon.
411      *
412      * @return the text alignment
413      */

414     public Alignment getTextAlignment() {
415         return (Alignment) getProperty(PROPERTY_TEXT_ALIGNMENT);
416     }
417
418     /**
419      * Returns the position of the text relative to the icon.
420      *
421      * @return the text position
422      */

423     public Alignment getTextPosition() {
424         return (Alignment) getProperty(PROPERTY_TEXT_POSITION);
425     }
426     
427     /**
428      * Returns the tool tip text (displayed when the mouse cursor is hovered
429      * over the component).
430      *
431      * @return the tool tip text
432      */

433     public String JavaDoc getToolTipText() {
434         return (String JavaDoc) getProperty(PROPERTY_TOOL_TIP_TEXT);
435     }
436     
437     /**
438      * Returns the width of the button.
439      * This property supports <code>Extent</code>s with
440      * fixed or percentile units.
441      *
442      * @return the width
443      */

444     public Extent getWidth() {
445         return (Extent) getProperty(PROPERTY_WIDTH);
446     }
447
448     /**
449      * Determines if the button has any <code>ActionListener</code>s
450      * registered.
451      *
452      * @return true if any action listeners are registered
453      */

454     public boolean hasActionListeners() {
455         return hasEventListenerList() && getEventListenerList().getListenerCount(ActionListener.class) != 0;
456     }
457     
458     /**
459      * Determines if the text of the button should wrap in the event that
460      * horizontal space is limited. Default value is true.
461      *
462      * @return the line wrap state
463      */

464     public boolean isLineWrap() {
465         Boolean JavaDoc value = (Boolean JavaDoc) getProperty(PROPERTY_LINE_WRAP);
466         return value == null ? true : value.booleanValue();
467     }
468     
469     /**
470      * Determines if pressed effects are enabled.
471      *
472      * @return true if pressed effects are enabled
473      * @see #setPressedEnabled(boolean)
474      */

475     public boolean isPressedEnabled() {
476         Boolean JavaDoc value = (Boolean JavaDoc) getProperty(PROPERTY_PRESSED_ENABLED);
477         return value == null ? false : value.booleanValue();
478     }
479
480     /**
481      * Determines if rollover effects are enabled.
482      *
483      * @return true if rollover effects are enabled
484      * @see #setRolloverEnabled(boolean)
485      */

486     public boolean isRolloverEnabled() {
487         Boolean JavaDoc value = (Boolean JavaDoc) getProperty(PROPERTY_ROLLOVER_ENABLED);
488         return value == null ? false : value.booleanValue();
489     }
490
491     /**
492      * This component does not support children.
493      *
494      * @see nextapp.echo2.app.Component#isValidChild(nextapp.echo2.app.Component)
495      */

496     public boolean isValidChild(Component component) {
497         return false;
498     }
499
500     /**
501      * @see nextapp.echo2.app.Component#processInput(java.lang.String, java.lang.Object)
502      */

503     public void processInput(String JavaDoc name, Object JavaDoc value) {
504         super.processInput(name, value);
505         if (INPUT_CLICK.equals(name)) {
506             doAction();
507         }
508     }
509
510     /**
511      * Removes an <code>ActionListener</code> from being notified of user
512      * actions, i.e., button presses.
513      *
514      * @param l the listener to remove
515      */

516     public void removeActionListener(ActionListener l) {
517         if (!hasEventListenerList()) {
518             return;
519         }
520         getEventListenerList().removeListener(ActionListener.class, l);
521         // Notification of action listener changes is provided due to
522
// existence of hasActionListeners() method.
523
firePropertyChange(ACTION_LISTENERS_CHANGED_PROPERTY, l, null);
524     }
525
526     /**
527      * Sets the action command of the <code>ButtonModel</code>.
528      *
529      * @param newValue the action command
530      * @see nextapp.echo2.app.button.ButtonModel#setActionCommand(java.lang.String)
531      */

532     public void setActionCommand(String JavaDoc newValue) {
533         getModel().setActionCommand(newValue);
534     }
535     
536     /**
537      * Sets the alignment of the button's content.
538      * Only horizontal alignments are supported.
539      *
540      * @param newValue the new alignment
541      */

542     public void setAlignment(Alignment newValue) {
543         setProperty(PROPERTY_ALIGNMENT, newValue);
544     }
545
546     /**
547      * Sets the background image of the button.
548      *
549      * @param newValue the new background image
550      */

551     public void setBackgroundImage(FillImage newValue) {
552         setProperty(PROPERTY_BACKGROUND_IMAGE, newValue);
553     }
554
555     /**
556      * Sets the border displayed around the button.
557      *
558      * @param newValue the new border
559      */

560     public void setBorder(Border newValue) {
561         setProperty(PROPERTY_BORDER, newValue);
562     }
563
564     /**
565      * Sets the background color of the button when the button is disabled.
566      *
567      * @param newValue the new <code>Color</code>
568      */

569     public void setDisabledBackground(Color newValue) {
570         setProperty(PROPERTY_DISABLED_BACKGROUND, newValue);
571     }
572
573     /**
574      * Sets the background image displayed when the button is disabled.
575      *
576      * @param newValue the new background image
577      */

578     public void setDisabledBackgroundImage(FillImage newValue) {
579         setProperty(PROPERTY_DISABLED_BACKGROUND_IMAGE, newValue);
580     }
581
582     /**
583      * Sets the border displayed around the button when the button is disabled.
584      *
585      * @param newValue the new border
586      */

587     public void setDisabledBorder(Border newValue) {
588         setProperty(PROPERTY_DISABLED_BORDER, newValue);
589     }
590
591     /**
592      * Sets the font of the button when the button is disabled.
593      *
594      * @param newValue the new <code>Font</code>
595      */

596     public void setDisabledFont(Font newValue) {
597         setProperty(PROPERTY_DISABLED_FONT, newValue);
598     }
599
600     /**
601      * Sets the foreground color of the button when the button is disabled.
602      *
603      * @param newValue the new <code>Color</code>
604      */

605     public void setDisabledForeground(Color newValue) {
606         setProperty(PROPERTY_DISABLED_FOREGROUND, newValue);
607     }
608
609     /**
610      * Sets the icon of the button that is displayed when the button is
611      * disabled.
612      *
613      * @param newValue the new icon
614      */

615     public void setDisabledIcon(ImageReference newValue) {
616         setProperty(PROPERTY_DISABLED_ICON, newValue);
617     }
618
619     /**
620      * Sets the height of the button.
621      * This property only supports <code>Extent</code>s with
622      * fixed (i.e., not percent) units.
623      *
624      * @param newValue the new height
625      */

626     public void setHeight(Extent newValue) {
627         setProperty(PROPERTY_HEIGHT, newValue);
628     }
629
630     /**
631      * Sets the icon displayed in the button.
632      *
633      * @param newValue the new icon
634      */

635     public void setIcon(ImageReference newValue) {
636         setProperty(PROPERTY_ICON, newValue);
637     }
638
639     /**
640      * Sets the margin size between the icon and the text.
641      * The margin will only be displayed if the button has both
642      * icon and text properties set.
643      * This property only supports <code>Extent</code>s with
644      * fixed (i.e., not percent) units.
645      *
646      * @param newValue the margin size
647      */

648     public void setIconTextMargin(Extent newValue) {
649         setProperty(PROPERTY_ICON_TEXT_MARGIN, newValue);
650     }
651
652     /**
653      * Sets the margin between the buttons edge and its content.
654      *
655      * @param newValue the new margin
656      */

657     public void setInsets(Insets newValue) {
658         setProperty(PROPERTY_INSETS, newValue);
659     }
660
661     /**
662      * Sets whether the text of the button should wrap in the event that
663      * horizontal space is limited. Default value is true.
664      *
665      * @param newValue the new line wrap state
666      */

667     public void setLineWrap(boolean newValue) {
668         setProperty(PROPERTY_LINE_WRAP, new Boolean JavaDoc(newValue));
669     }
670     
671     /**
672      * Sets the model that this button represents. The model may not be null.
673      *
674      * @param newValue the new <code>ButtonModel</code>
675      */

676     public void setModel(ButtonModel newValue) {
677         if (newValue == null) {
678             throw new IllegalArgumentException JavaDoc("Model may not be null.");
679         }
680
681         ButtonModel oldValue = getModel();
682
683         if (oldValue != null) {
684             oldValue.removeActionListener(actionForwarder);
685         }
686
687         newValue.addActionListener(actionForwarder);
688
689         setProperty(PROPERTY_MODEL, newValue);
690     }
691
692     /**
693      * Sets the background color of the button when the button is pressed.
694      *
695      * @param newValue the new <code>Color</code>
696      */

697     public void setPressedBackground(Color newValue) {
698         setProperty(PROPERTY_PRESSED_BACKGROUND, newValue);
699     }
700
701     /**
702      * Sets the background image displayed when the button is pressed.
703      *
704      * @param newValue the new background image
705      */

706     public void setPressedBackgroundImage(FillImage newValue) {
707         setProperty(PROPERTY_PRESSED_BACKGROUND_IMAGE, newValue);
708     }
709
710     /**
711      * Sets the border displayed around the button when the button is pressed.
712      *
713      * @param newValue the new border
714      */

715     public void setPressedBorder(Border newValue) {
716         setProperty(PROPERTY_PRESSED_BORDER, newValue);
717     }
718
719     /**
720      * Sets whether pressed effects are enabled when the button is pressed.
721      * Pressed properties have no effect unless this property is set to true.
722      * The default value is false.
723      *
724      * @param newValue true if pressed effects should be enabled
725      */

726     public void setPressedEnabled(boolean newValue) {
727         setProperty(PROPERTY_PRESSED_ENABLED, new Boolean JavaDoc(newValue));
728     }
729
730     /**
731      * Sets the font of the button when the button is pressed.
732      *
733      * @param newValue the new <code>Font</code>
734      */

735     public void setPressedFont(Font newValue) {
736         setProperty(PROPERTY_PRESSED_FONT, newValue);
737     }
738
739     /**
740      * Sets the foreground color of the button when the button is pressed.
741      *
742      * @param newValue the new <code>Color</code>
743      */

744     public void setPressedForeground(Color newValue) {
745         setProperty(PROPERTY_PRESSED_FOREGROUND, newValue);
746     }
747
748     /**
749      * Sets the icon of the button that is displayed when the button is pressed.
750      *
751      * @param newValue the new icon
752      */

753     public void setPressedIcon(ImageReference newValue) {
754         setProperty(PROPERTY_PRESSED_ICON, newValue);
755     }
756
757     /**
758      * Sets the background color of the button when the mouse cursor is inside
759      * its bounds.
760      *
761      * @param newValue the new <code>Color</code>
762      */

763     public void setRolloverBackground(Color newValue) {
764         setProperty(PROPERTY_ROLLOVER_BACKGROUND, newValue);
765     }
766
767     /**
768      * Sets the background image displayed when the mouse cursor is inside the
769      * button's bounds
770      *
771      * @param newValue the new background image
772      */

773     public void setRolloverBackgroundImage(FillImage newValue) {
774         setProperty(PROPERTY_ROLLOVER_BACKGROUND_IMAGE, newValue);
775     }
776
777     /**
778      * Sets the border displayed around the button when the mouse cursor is
779      * inside its bounds.
780      *
781      * @param newValue the new border
782      */

783     public void setRolloverBorder(Border newValue) {
784         setProperty(PROPERTY_ROLLOVER_BORDER, newValue);
785     }
786
787     /**
788      * Sets whether rollover effects are enabled when the mouse cursor is inside
789      * the button's bounds. Rollover properties have no effect unless this
790      * property is set to true. The default value is false.
791      *
792      * @param newValue true if rollover effects should be enabled
793      */

794     public void setRolloverEnabled(boolean newValue) {
795         setProperty(PROPERTY_ROLLOVER_ENABLED, new Boolean JavaDoc(newValue));
796     }
797
798     /**
799      * Sets the font of the button when the mouse cursor is inside its bounds.
800      *
801      * @param newValue the new <code>Font</code>
802      */

803     public void setRolloverFont(Font newValue) {
804         setProperty(PROPERTY_ROLLOVER_FONT, newValue);
805     }
806
807     /**
808      * Sets the foreground color of the button when the mouse cursor is inside
809      * its bounds.
810      *
811      * @param newValue the new <code>Color</code>
812      */

813     public void setRolloverForeground(Color newValue) {
814         setProperty(PROPERTY_ROLLOVER_FOREGROUND, newValue);
815     }
816
817     /**
818      * Sets the icon of the button that is displayed when the mouse cursor is
819      * inside its bounds.
820      *
821      * @param newValue the new icon
822      */

823     public void setRolloverIcon(ImageReference newValue) {
824         setProperty(PROPERTY_ROLLOVER_ICON, newValue);
825     }
826
827     /**
828      * Sets the text label of the button.
829      *
830      * @param newValue the new text label
831      */

832     public void setText(String JavaDoc newValue) {
833         setProperty(PROPERTY_TEXT, newValue);
834     }
835
836     /**
837      * Sets the alignment of the text relative to the icon.
838      * Note that only one of the provided <code>Alignment</code>'s
839      * settings should be non-default.
840      *
841      * @param newValue the new text alignment
842      */

843     public void setTextAlignment(Alignment newValue) {
844         setProperty(PROPERTY_TEXT_ALIGNMENT, newValue);
845     }
846     
847     /**
848      * Sets the position of the text relative to the icon.
849      * Note that only one of the provided <code>Alignment</code>'s
850      * settings should be non-default.
851      *
852      * @param newValue the new text position
853      */

854     public void setTextPosition(Alignment newValue) {
855         setProperty(PROPERTY_TEXT_POSITION, newValue);
856     }
857     
858     /**
859      * Sets the tool tip text (displayed when the mouse cursor is hovered
860      * over the component).
861      *
862      * @param newValue the new tool tip text
863      */

864     public void setToolTipText(String JavaDoc newValue) {
865         setProperty(PROPERTY_TOOL_TIP_TEXT, newValue);
866     }
867
868     /**
869      * Sets the width of the button.
870      * This property supports <code>Extent</code>s with
871      * fixed or percentile units.
872      *
873      * @param newValue the new width
874      */

875     public void setWidth(Extent newValue) {
876         setProperty(PROPERTY_WIDTH, newValue);
877     }
878 }
Popular Tags