Search in sources :

Example 1 with CheckBoxTableCell

use of javafx.scene.control.cell.CheckBoxTableCell in project Gargoyle by callakrsos.

the class CrudBaseColumnMapper method checkBox.

private CheckBoxTableCell<T, Object> checkBox(TableColumn<T, ?> column) {
    CheckBox columnheaderCheckbox = new CheckBox();
    // columnheaderCheckbox.setStyle("-fx-background-color:white;
    // -fx-border-color :black; -fx-border-width:1;");
    column.setGraphic(columnheaderCheckbox);
    column.setSortable(false);
    columnheaderCheckbox.addEventHandler(ActionEvent.ACTION, event -> {
        if (columnheaderCheckbox.isSelected()) {
            setSelectAll(column, true);
        } else {
            setSelectAll(column, false);
        }
    });
    return new CheckBoxTableCell<T, Object>() {

        @Override
        public void updateItem(Object item, boolean empty) {
            super.updateItem(item, empty);
        }

        @Override
        public void startEdit() {
            //TODO 추가 작업 예상됨. 현재는 기본컬럼으로 CheckBox형태가 나올것같지않음.
            super.startEdit();
        }
    };
}
Also used : CheckBox(javafx.scene.control.CheckBox) CheckBoxTableCell(javafx.scene.control.cell.CheckBoxTableCell)

Example 2 with CheckBoxTableCell

use of javafx.scene.control.cell.CheckBoxTableCell in project Gargoyle by callakrsos.

the class CheckBoxTableCellExam method start.

/*
	 * (non-Javadoc)
	 *
	 * @see javafx.application.Application#start(javafx.stage.Stage)
	 */
@Override
public void start(Stage primaryStage) throws Exception {
    TableView<SampleVO> center = new TableView<>();
    center.setEditable(true);
    TableColumn<SampleVO, Boolean> e = new TableColumn<SampleVO, Boolean>();
    e.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<SampleVO, Boolean>, ObservableValue<Boolean>>() {

        @Override
        public ObservableValue<Boolean> call(CellDataFeatures<SampleVO, Boolean> param) {
            return param.getValue().checked;
        }
    });
    e.setCellFactory(new Callback<TableColumn<SampleVO, Boolean>, TableCell<SampleVO, Boolean>>() {

        @Override
        public TableCell<SampleVO, Boolean> call(TableColumn<SampleVO, Boolean> param) {
            return new CheckBoxTableCell<SampleVO, Boolean>() {

                /*
					 * (non-Javadoc)
					 *
					 * @see
					 * javafx.scene.control.cell.CheckBoxTableCell#updateItem(
					 * java.lang.Object, boolean)
					 */
                @Override
                public void updateItem(Boolean item, boolean empty) {
                    super.updateItem(item, empty);
                }

                /*
					 * (non-Javadoc)
					 *
					 * @see
					 * javafx.scene.control.Cell#isItemChanged(java.lang.Object,
					 * java.lang.Object)
					 */
                @Override
                protected boolean isItemChanged(Boolean oldItem, Boolean newItem) {
                    System.out.println(oldItem + " : " + newItem);
                    return super.isItemChanged(oldItem, newItem);
                }
            };
        }
    });
    e.setEditable(true);
    TableColumn<SampleVO, String> e2 = new TableColumn<SampleVO, String>();
    e2.setCellValueFactory(new PropertyValueFactory<SampleVO, String>("name"));
    center.getColumns().add(e);
    center.getColumns().add(e2);
    center.getItems().add(new SampleVO(true, "kim"));
    center.getItems().add(new SampleVO(true, "young"));
    BorderPane borderPane = new BorderPane(center);
    primaryStage.setScene(new Scene(borderPane));
    primaryStage.show();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) CellDataFeatures(javafx.scene.control.TableColumn.CellDataFeatures) ObservableValue(javafx.beans.value.ObservableValue) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) CheckBoxTableCell(javafx.scene.control.cell.CheckBoxTableCell) SampleVO(com.kyj.fx.voeditor.visual.example.CheckBoxTableCellExam.SampleVO) TableView(javafx.scene.control.TableView)

Aggregations

CheckBoxTableCell (javafx.scene.control.cell.CheckBoxTableCell)2 SampleVO (com.kyj.fx.voeditor.visual.example.CheckBoxTableCellExam.SampleVO)1 ObservableValue (javafx.beans.value.ObservableValue)1 Scene (javafx.scene.Scene)1 CheckBox (javafx.scene.control.CheckBox)1 TableCell (javafx.scene.control.TableCell)1 TableColumn (javafx.scene.control.TableColumn)1 CellDataFeatures (javafx.scene.control.TableColumn.CellDataFeatures)1 TableView (javafx.scene.control.TableView)1 BorderPane (javafx.scene.layout.BorderPane)1