package jtaDiscRack.presentation.dpanels;
import jtaDiscRack.presentation.delements.*;
import javax.swing.*;
import java.awt.*;
/**
* Creates a panel with check button.
*
* @author Sasa Bojanic
* @version 1.0
*/
public class DCheckPanel extends DPanel {
private JCheckBox jcb;
public DCheckPanel (DSimpleElement myOwner) {
super(myOwner,2,"",false,false);
JLabel jl=new JLabel(myOwner.toName()+": ");
jl.setAlignmentX(Component.LEFT_ALIGNMENT);
jl.setAlignmentY(Component.TOP_ALIGNMENT);
jl.setHorizontalAlignment(SwingConstants.RIGHT);
jcb=new JCheckBox();
if (myOwner.toValue()!=null && myOwner.toValue() instanceof Boolean) {
jcb.setSelected(((Boolean)myOwner.toValue()).booleanValue());
}
jcb.setAlignmentX(Component.LEFT_ALIGNMENT);
jcb.setAlignmentY(Component.TOP_ALIGNMENT);
jcb.setMinimumSize(new Dimension(textFieldDimension));
jcb.setMaximumSize(new Dimension(textFieldDimension));
jcb.setPreferredSize(new Dimension(textFieldDimension));
add(Box.createHorizontalGlue());
add(jl);
add(jcb);
}
public JCheckBox getCheckBox () {
return jcb;
}
public void setElements () {
getOwner().setValue(new Boolean(jcb.isSelected()));
}
}
|