All Classes Namespaces Files Functions Variables
CheckBoxChooser.java
Go to the documentation of this file.
1 package fi.jyu.mit.fxgui;
2 
3 import java.util.ArrayList;
4 
5 import javafx.beans.value.ChangeListener;
6 import javafx.scene.control.CheckBox;
7 
8 /**
9  * Simple CheckBoxchooser
10  * @author terop
11  *@version 13.1.2017
12  * @param <T> type of objects to save
13  */
14 public class CheckBoxChooser<T> extends BaseBoxChooser<T, CheckBox> {
15 
16  @Override
17  protected void removeListener(CheckBox node, ArrayList<ChangeListener<Boolean>> list) {
18  for (ChangeListener<Boolean> changeListener : list) {
19  node.selectedProperty().removeListener(changeListener);
20  }
21 
22  }
23 
24 
25  @Override
26  protected CheckBox addCorrectComponent(String name, T object) {
27  CheckBox box = new CheckBox(name);
28  box.setMnemonicParsing(true);
29  return box;
30  }
31 
32 
33  @Override
34  protected void addChangeListener(CheckBox box, ChangeListener<Boolean> listener) {
35  box.selectedProperty().addListener(listener);
36  }
37 
38 
39  @Override
40  protected boolean isComponentSelected(CheckBox component) {
41  return component.selectedProperty().get();
42  }
43 
44 
45  @Override
46  protected boolean setComponentSelected(CheckBox component, boolean value) {
47  boolean oldSelect = isComponentSelected(component);
48  component.selectedProperty().set(value);
49  return oldSelect;
50  }
51 
52 }