Java CheckBox .allowIndeterminateProperty ()

Syntax

CheckBox.allowIndeterminateProperty() has the following syntax.

public final BooleanProperty allowIndeterminateProperty()

Example

In the following code shows how to use CheckBox.allowIndeterminateProperty() method.


import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.CheckBox;
import javafx.stage.Stage;
/* w  ww  .jav a  2  s  .  c  o m*/
public class Main extends Application {
    public static void main(String[] args) {
        launch(args);
    }
    @Override
    public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        stage.setWidth(300);
        stage.setHeight(150);
        final CheckBox cb = new CheckBox();
        cb.setText("checkBox");
        cb.setAllowIndeterminate(true);
        
        cb.allowIndeterminateProperty().addListener(new ChangeListener<Boolean>() {
           public void changed(ObservableValue<? extends Boolean> ov,
             Boolean old_val, Boolean new_val) {
             System.out.println(cb.isSelected());
             System.out.println(cb.isIndeterminate());
          }
        });
        ((Group) scene.getRoot()).getChildren().add(cb);

        stage.setScene(scene);
        stage.show();
    }
}




















Home »
  Java Tutorial »
    javafx.scene.control »




Accordion
Button
CheckBox
CheckMenuItem
ChoiceBox
ComboBox
ContextMenu
Label
Menu
ProgressBar
ToggleButton
ToolBar
Tooltip
TreeItem
TreeView