Example usage for javafx.scene.control CheckBox CheckBox

List of usage examples for javafx.scene.control CheckBox CheckBox

Introduction

In this page you can find the example usage for javafx.scene.control CheckBox CheckBox.

Prototype

public CheckBox() 

Source Link

Document

Creates a check box with an empty string for its label.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(300);//  w w w. j av a  2 s . c o  m
    stage.setHeight(150);
    final CheckBox cb = new CheckBox();
    cb.setText("checkBox");

    cb.selectedProperty().addListener(new ChangeListener<Boolean>() {
        public void changed(ObservableValue<? extends Boolean> ov, Boolean old_val, Boolean new_val) {
            System.out.println(cb.isSelected());
        }
    });
    ((Group) scene.getRoot()).getChildren().add(cb);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(300);//from   ww  w.  j  ava2 s  .  c o  m
    stage.setHeight(150);
    final CheckBox cb = new CheckBox();
    cb.setText("checkBox");
    cb.setSelected(true);

    cb.selectedProperty().addListener(new ChangeListener<Boolean>() {
        public void changed(ObservableValue<? extends Boolean> ov, Boolean old_val, Boolean new_val) {
            System.out.println(cb.isSelected());
        }
    });
    ((Group) scene.getRoot()).getChildren().add(cb);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(300);/*w ww.  j av  a  2 s .c o  m*/
    stage.setHeight(150);
    final CheckBox cb = new CheckBox();
    cb.setText("checkBox");
    cb.setAllowIndeterminate(true);

    cb.indeterminateProperty().addListener(new ChangeListener<Boolean>() {
        public void changed(ObservableValue<? extends Boolean> ov, Boolean old_val, Boolean new_val) {
            System.out.println(cb.isSelected());
        }
    });
    ((Group) scene.getRoot()).getChildren().add(cb);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(300);// w ww .  ja v  a  2s . c  om
    stage.setHeight(150);
    final CheckBox cb = new CheckBox();
    cb.setText("checkBox");
    cb.setAllowIndeterminate(true);

    cb.selectedProperty().addListener(new ChangeListener<Boolean>() {
        public void changed(ObservableValue<? extends Boolean> ov, Boolean old_val, Boolean new_val) {
            System.out.println(cb.isSelected());
        }
    });
    ((Group) scene.getRoot()).getChildren().add(cb);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(300);/*from w  w w . j a  v  a 2 s . c o m*/
    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();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(300);/*w ww. j a va2  s  .  c o  m*/
    stage.setHeight(150);
    final CheckBox cb = new CheckBox();
    cb.setText("checkBox");
    cb.setAllowIndeterminate(true);

    cb.selectedProperty().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();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(300);/*from  www.ja  va  2 s .c o m*/
    stage.setHeight(150);
    final CheckBox cb = new CheckBox();
    cb.setText("checkBox");
    cb.setAllowIndeterminate(true);

    cb.selectedProperty().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.isAllowIndeterminate());
        }
    });
    ((Group) scene.getRoot()).getChildren().add(cb);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(300);/* ww w  .  j  a v a 2  s. com*/
    stage.setHeight(150);
    final CheckBox cb = new CheckBox();
    cb.setText("checkBox");
    final Tooltip tooltip = new Tooltip("$ tooltip");
    tooltip.setFont(new Font("Arial", 16));
    cb.setTooltip(tooltip);
    cb.selectedProperty().addListener(new ChangeListener<Boolean>() {
        public void changed(ObservableValue<? extends Boolean> ov, Boolean old_val, Boolean new_val) {
            System.out.println(cb.isSelected());
        }
    });

    ((Group) scene.getRoot()).getChildren().add(cb);

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

From source file:com.exalttech.trex.ui.views.importPcap.ImportedPacketTableView.java

/**
 * Initialize table rows and columns//w ww  .  ja v  a2 s .c o m
 */
private void initTableRowsColumns() {

    selectedColumn.setCellValueFactory(new PropertyValueFactory<>("selected"));
    selectedColumn.setCellFactory(CheckBoxTableCell.forTableColumn(selectedColumn));
    selectAll = new CheckBox();
    selectAll.getStyleClass().add("selectAll");
    selectAll.setSelected(true);
    selectAll.selectedProperty().addListener(
            (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
                selectAllRows();
            });
    selectedColumn.setGraphic(selectAll);

    nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
    nameColumn.setCellFactory(new TextFieldTableViewCell());

    packetNumColumn.setCellValueFactory(new PropertyValueFactory<>("index"));
    lengthColumn.setCellValueFactory(new PropertyValueFactory<>("length"));
    macSrcColumn.setCellValueFactory(new PropertyValueFactory<>("macSrc"));
    macDstColumn.setCellValueFactory(new PropertyValueFactory<>("macDst"));
    ipSrcColumn.setCellValueFactory(new PropertyValueFactory<>("ipSrc"));
    ipDstColumn.setCellValueFactory(new PropertyValueFactory<>("ipDst"));
    packetTypeColumn.setCellValueFactory(new PropertyValueFactory<>("packetType"));

    importedStreamTable.setRowFactory(highlightedRowFactory);

}

From source file:com.bdb.weather.display.preferences.ColorPreferencePanel.java

public ColorPreferencePanel() {
    VBox vbox = new VBox();
    GridPane colorPanel = new GridPane();

    for (ColorPreferenceEntry entry : entries2) {
        ColorPicker colorPicker = new ColorPicker(preferences.getColorPref(entry.preferenceName));
        entry.button = colorPicker;//from  w w w .  j av  a2  s.  c  om
        colorPanel.add(new Label(entry.preferenceName), 0, entry.row);
        colorPanel.add(colorPicker, 1, entry.row);
    }

    GridPane plotColorPanel = new GridPane();

    int gridx = 0;
    int gridy = 0;

    //
    // Layout the column headers
    //
    for (int i = 0; i < COLOR_COL_HEADERS.length; i++) {
        gridx = i;
        plotColorPanel.add(new Label(COLOR_COL_HEADERS[i]), gridx, gridy);
    }

    //
    // Layout the row leaders
    //
    //c.anchor = GridBagConstraints.EAST;
    for (String header : COLOR_ROW_HEADERS) {
        gridx = 0;
        gridy++;
        plotColorPanel.add(new Label(header), gridx, gridy);

        gridx = 5;

        Set<String> names = ColorSchemeCollection.getColorSchemeNames();
        ComboBox<String> scheme = new ComboBox<>();
        scheme.getItems().addAll(names);
        scheme.setUserData(gridy);
        plotColorPanel.add(scheme, gridx, gridy);
        scheme.setOnAction((ActionEvent e) -> {
            ComboBox<String> cb = (ComboBox<String>) e.getSource();
            applyColorScheme((Integer) cb.getUserData(), cb.getSelectionModel().getSelectedItem());
        });
        gridx = 6;
        CheckBox showSeries = new CheckBox();
        showSeries.setUserData(gridy);
        plotColorPanel.add(showSeries, gridx, gridy);
        showSeries.setOnAction((ActionEvent e) -> {
            CheckBox cb = (CheckBox) e.getSource();
            int row = (Integer) cb.getUserData();
            for (ColorPreferenceEntry entry : entries) {
                if (entry.row == row) {
                    addRemoveSeries(entry.preferenceName, cb.isSelected());
                }
            }
            createSeriesData();
            configureRenderer();
        });
    }

    //c.anchor = GridBagConstraints.CENTER;
    for (ColorPreferenceEntry entry : entries) {
        gridx = entry.column;
        gridy = entry.row;
        ColorPicker button = new ColorPicker();
        button.setValue(preferences.getColorPref(entry.preferenceName));
        //button.setPrefSize(10, 10);
        button.setUserData(entry);
        plotColorPanel.add(button, gridx, gridy);
        entry.button = button;
    }

    JFreeChart chart = ChartFactory.createXYLineChart("Example", "X Axis", "Y Axis", dataset,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(renderer);

    ChartViewer graphExamplePanel = new ChartViewer(chart);

    vbox.getChildren().addAll(colorPanel, plotColorPanel);
    setTop(vbox);
    setCenter(graphExamplePanel);
    FlowPane buttonPanel = new FlowPane();
    Button button = new Button("OK");
    button.setOnAction((ActionEvent e) -> {
        saveData();
    });
    buttonPanel.getChildren().add(button);
    setBottom(buttonPanel);
}