KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > userinterface > UPBooleanCheckBox


1 package com.calipso.reportgenerator.userinterface;
2
3 import javax.swing.*;
4 import java.awt.*;
5
6 /**
7  * Representa un componente <code>JPanel</code> a incluirse en una instancia
8  * de <code>UPRangePanel</code> o <code>UPValuePanel</code>.
9  * 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, boolean isDoubleBuffered) {
19     super(layout, isDoubleBuffered);
20     initialize();
21   }
22
23   public UPBooleanCheckBox(LayoutManager layout) {
24     super(layout);
25     initialize();
26   }
27
28   public UPBooleanCheckBox(boolean isDoubleBuffered) {
29     super(isDoubleBuffered);
30     initialize();
31   }
32
33   public UPBooleanCheckBox() {
34     initialize();
35   }
36
37   private void initialize() {
38     setLayout(new FlowLayout());
39     ButtonGroup group = new ButtonGroup();
40     btTrue = new JRadioButton("True");
41     btTrue.setSelected(true);
42     btFalse = new JRadioButton("False");
43     btFalse.setSelected(false);
44     group.add(btTrue);
45     group.add(btFalse);
46     add(btTrue);
47     add(btFalse);
48   }
49
50   public Object JavaDoc getComponentValue() {
51     if(btTrue.isSelected()) {
52       return new Boolean JavaDoc("true");
53     } else {
54       return new Boolean JavaDoc("false");
55     }
56   }
57
58 }
59
Popular Tags