KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > discRack > presentation > dpanels > DCheckPanel


1 package discRack.presentation.dpanels;
2
3 import discRack.presentation.delements.*;
4
5 import java.util.*;
6 import javax.swing.*;
7
8 import java.awt.*;
9 import java.awt.event.*;
10
11 /**
12  * Creates a panel with check button.
13  *
14  * @author Sasa Bojanic
15  * @version 1.0
16  */

17 public class DCheckPanel extends DPanel {
18
19    private JCheckBox jcb;
20
21    public DCheckPanel (DSimpleElement myOwner) {
22
23       super(myOwner,2,"",false,false);
24
25       JLabel jl=new JLabel(myOwner.toName()+": ");
26       jl.setAlignmentX(Component.LEFT_ALIGNMENT);
27       jl.setAlignmentY(Component.TOP_ALIGNMENT);
28       jl.setHorizontalAlignment(SwingConstants.RIGHT);
29
30       jcb=new JCheckBox();
31       if (myOwner.toValue()!=null && myOwner.toValue() instanceof Boolean JavaDoc) {
32          jcb.setSelected(((Boolean JavaDoc)myOwner.toValue()).booleanValue());
33       }
34       jcb.setAlignmentX(Component.LEFT_ALIGNMENT);
35       jcb.setAlignmentY(Component.TOP_ALIGNMENT);
36       jcb.setMinimumSize(new Dimension(textFieldDimension));
37       jcb.setMaximumSize(new Dimension(textFieldDimension));
38       jcb.setPreferredSize(new Dimension(textFieldDimension));
39
40       add(Box.createHorizontalGlue());
41       add(jl);
42       add(jcb);
43    }
44
45    public JCheckBox getCheckBox () {
46       return jcb;
47    }
48
49    public void setElements () {
50       getOwner().setValue(new Boolean JavaDoc(jcb.isSelected()));
51    }
52
53 }
54
Popular Tags