01: package com.calipso.reportgenerator.userinterface;
02:
03: import javax.swing.*;
04: import java.awt.*;
05:
06: /**
07: * Representa un componente <code>JPanel</code> a incluirse en una instancia
08: * de <code>UPRangePanel</code> o <code>UPValuePanel</code>.
09: * Presenta un grupo de instancias de <code>JRadioButton</code> con los valores True y False.
10: * Devuelve un objeto <code>Boolean</code> segun los especificado en los botones.
11: */
12:
13: public class UPBooleanCheckBox extends JPanel implements UPComponent {
14:
15: private JRadioButton btTrue;
16: private JRadioButton btFalse;
17:
18: public UPBooleanCheckBox(LayoutManager layout,
19: boolean isDoubleBuffered) {
20: super (layout, isDoubleBuffered);
21: initialize();
22: }
23:
24: public UPBooleanCheckBox(LayoutManager layout) {
25: super (layout);
26: initialize();
27: }
28:
29: public UPBooleanCheckBox(boolean isDoubleBuffered) {
30: super (isDoubleBuffered);
31: initialize();
32: }
33:
34: public UPBooleanCheckBox() {
35: initialize();
36: }
37:
38: private void initialize() {
39: setLayout(new FlowLayout());
40: ButtonGroup group = new ButtonGroup();
41: btTrue = new JRadioButton("True");
42: btTrue.setSelected(true);
43: btFalse = new JRadioButton("False");
44: btFalse.setSelected(false);
45: group.add(btTrue);
46: group.add(btFalse);
47: add(btTrue);
48: add(btFalse);
49: }
50:
51: public Object getComponentValue() {
52: if (btTrue.isSelected()) {
53: return new Boolean("true");
54: } else {
55: return new Boolean("false");
56: }
57: }
58:
59: }
|