package com.javamarcher.window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.AbstractButton;
import javax.swing.JCheckBox;
import com.javamarcher.util.ActionGeneric;
public class LabeledCheckBox extends LabelBasedUIComponent {
private final JCheckBox checkBox = new JCheckBox();
public LabeledCheckBox(String label, boolean startValue, ActionGeneric<Boolean> changeAction) {
super(label);
checkBox.setSelected(startValue);
checkBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final AbstractButton button = (AbstractButton) e.getSource();
changeAction.performAction(button.isSelected());
}
});
addComponentToContainer(checkBox);
}
}