01: package discRack.presentation.dpanels;
02:
03: import discRack.presentation.delements.*;
04:
05: import java.util.*;
06: import javax.swing.*;
07:
08: import java.awt.*;
09: 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
32: && myOwner.toValue() instanceof Boolean) {
33: jcb.setSelected(((Boolean) myOwner.toValue())
34: .booleanValue());
35: }
36: jcb.setAlignmentX(Component.LEFT_ALIGNMENT);
37: jcb.setAlignmentY(Component.TOP_ALIGNMENT);
38: jcb.setMinimumSize(new Dimension(textFieldDimension));
39: jcb.setMaximumSize(new Dimension(textFieldDimension));
40: jcb.setPreferredSize(new Dimension(textFieldDimension));
41:
42: add(Box.createHorizontalGlue());
43: add(jl);
44: add(jcb);
45: }
46:
47: public JCheckBox getCheckBox() {
48: return jcb;
49: }
50:
51: public void setElements() {
52: getOwner().setValue(new Boolean(jcb.isSelected()));
53: }
54:
55: }
|