01: package com.salmonllc.swing;
02:
03: //** Copyright Statement ***************************************************
04: //The Salmon Open Framework for Internet Applications (SOFIA)
05: // Copyright (C) 1999 - 2002, Salmon LLC
06: //
07: // This program is free software; you can redistribute it and/or
08: // modify it under the terms of the GNU General Public License version 2
09: // as published by the Free Software Foundation;
10: //
11: // This program is distributed in the hope that it will be useful,
12: // but WITHOUT ANY WARRANTY; without even the implied warranty of
13: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: // GNU General Public License for more details.
15: //
16: // You should have received a copy of the GNU General Public License
17: // along with this program; if not, write to the Free Software
18: // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19: //
20: // For more information please visit http://www.salmonllc.com
21: //** End Copyright Statement ***************************************************
22:
23: import javax.swing.*;
24:
25: /**
26: * SOFIA implementation of a Toggle Button. This toggle button should be used in conjunction with an SButton group and functionally is similar to a radio button where one button in the group can be selected at a time. Binding to a datastore is accomplished through the SButtonGroup component.
27: */
28: public class SGroupedToggleButton extends JToggleButton {
29:
30: private SOption _opt;
31:
32: /***
33: * Creates a new Grouped Toggle Button with the specified option
34: */
35: public SGroupedToggleButton(SOption opt) {
36: super (opt.getDisplay());
37: _opt = opt;
38: }
39:
40: /***
41: * Creates a new Grouped Toggle Button with the specified option
42: */
43: public SGroupedToggleButton(String key, String display) {
44: super (display);
45: _opt = new SOption(key, display);
46: }
47:
48: /***
49: * Creates a new Grouped Toggle Button with the specified option
50: */
51: public SGroupedToggleButton(String key, String display, Icon icon) {
52: this (key, display);
53: setIcon(icon);
54: }
55:
56: /***
57: * Creates a new Grouped Toggle Button with the specified option
58: */
59: public SGroupedToggleButton(String key, Icon icon) {
60: super (icon);
61: _opt = new SOption(key, null);
62: }
63:
64: /***
65: * Creates a new Grouped Toggle Button with the specified option
66: */
67: public SGroupedToggleButton(SOption opt, Icon icon) {
68: super (icon);
69: _opt = opt;
70: }
71:
72: /***
73: * Returns the option from the Toggle Button
74: */
75: public SOption getOption() {
76: return _opt;
77: }
78: }
|