01: package jtaDiscRack.presentation.dpanels;
02:
03: import jtaDiscRack.presentation.delements.*;
04:
05: import javax.swing.*;
06: import java.awt.*;
07:
08: /**
09: * Creates a panel with check button.
10: *
11: * @author Sasa Bojanic
12: * @version 1.0
13: */
14: public class DCheckPanel extends DPanel {
15:
16: private JCheckBox jcb;
17:
18: public DCheckPanel(DSimpleElement myOwner) {
19:
20: super (myOwner, 2, "", false, false);
21:
22: JLabel jl = new JLabel(myOwner.toName() + ": ");
23: jl.setAlignmentX(Component.LEFT_ALIGNMENT);
24: jl.setAlignmentY(Component.TOP_ALIGNMENT);
25: jl.setHorizontalAlignment(SwingConstants.RIGHT);
26:
27: jcb = new JCheckBox();
28: if (myOwner.toValue() != null
29: && myOwner.toValue() instanceof Boolean) {
30: jcb.setSelected(((Boolean) myOwner.toValue())
31: .booleanValue());
32: }
33: jcb.setAlignmentX(Component.LEFT_ALIGNMENT);
34: jcb.setAlignmentY(Component.TOP_ALIGNMENT);
35: jcb.setMinimumSize(new Dimension(textFieldDimension));
36: jcb.setMaximumSize(new Dimension(textFieldDimension));
37: jcb.setPreferredSize(new Dimension(textFieldDimension));
38:
39: add(Box.createHorizontalGlue());
40: add(jl);
41: add(jcb);
42: }
43:
44: public JCheckBox getCheckBox() {
45: return jcb;
46: }
47:
48: public void setElements() {
49: getOwner().setValue(new Boolean(jcb.isSelected()));
50: }
51:
52: }
|