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 Radio Button. It takes an SOption with a key and display value. This component can't be bound directly to a datastore. It is instead bound via the SButtonGroup object.
27: */
28: public class SRadioButton extends JRadioButton {
29:
30: private SOption _opt;
31:
32: /***
33: * Creates a new Radio Button with an empty option
34: */
35: public SRadioButton() {
36: super (null, null, false);
37: _opt = new SOption();
38: }
39:
40: /***
41: * Creates a new Radio Button with the specified option
42: */
43: public SRadioButton(SOption opt) {
44: super (opt.getDisplay());
45: _opt = opt;
46: }
47:
48: /***
49: * Creates a new Radio Button with the specified option
50: */
51: public SRadioButton(String key, String display) {
52: super (display);
53: _opt = new SOption(key, display);
54: }
55:
56: /***
57: * Returns the option from the Radio Button
58: */
59: public SOption getOption() {
60: return _opt;
61: }
62:
63: /***
64: * Sets the option for the Radio Button
65: */
66: public void setOption(SOption sOpt) {
67: _opt = sOpt;
68: setText(_opt.getDisplay());
69: }
70: }
|