1 package be
.nikiroo
.utils
.ui
;
3 import javax
.swing
.JCheckBox
;
4 import javax
.swing
.JComponent
;
6 import be
.nikiroo
.utils
.resources
.MetaInfo
;
8 class ConfigItemBoolean
<E
extends Enum
<E
>> extends ConfigItem
<E
> {
9 private static final long serialVersionUID
= 1L;
12 * Create a new {@link ConfigItemBoolean} for the given {@link MetaInfo}.
15 * the {@link MetaInfo}
17 public ConfigItemBoolean(MetaInfo
<E
> info
) {
22 protected Object
getFromField(int item
) {
23 JCheckBox field
= (JCheckBox
) getField(item
);
25 return field
.isSelected();
32 protected Object
getFromInfo(int item
) {
33 return getInfo().getBoolean(item
, true);
37 protected void setToField(Object value
, int item
) {
38 JCheckBox field
= (JCheckBox
) getField(item
);
40 // Should not happen if config enum is correct
41 // (but this is not enforced)
46 field
.setSelected((Boolean
) value
);
51 protected void setToInfo(Object value
, int item
) {
52 getInfo().setBoolean((Boolean
) value
, item
);
56 protected JComponent
createEmptyField(int item
) {
58 if (getFromInfo(item
) == null) {
60 .println("No default value given for BOOLEAN parameter \""
62 + "\", we consider it is FALSE");
65 return new JCheckBox();