Last active
August 29, 2015 14:13
-
-
Save hendrikebbers/02439ed6993f7e8f1d8e to your computer and use it in GitHub Desktop.
JavaFX TableView that can't be selected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.guigarage.chapter6; | |
import javafx.application.Application; | |
import javafx.beans.property.SimpleObjectProperty; | |
import javafx.beans.property.SimpleStringProperty; | |
import javafx.collections.FXCollections; | |
import javafx.collections.ObservableList; | |
import javafx.scene.Scene; | |
import javafx.scene.control.TableColumn; | |
import javafx.scene.control.TablePosition; | |
import javafx.scene.control.TableView; | |
import javafx.scene.layout.StackPane; | |
import javafx.stage.Stage; | |
public class TableDemo2 extends Application { | |
@Override | |
public void start(Stage primaryStage) throws Exception { | |
TableView<String> table = new TableView<String>() { | |
@Override | |
public void requestFocus() { | |
} | |
}; | |
table.itemsProperty().get().addAll("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M"); | |
TableColumn<String, String> column = new TableColumn<>("Value"); | |
column.setCellValueFactory((f) -> new SimpleStringProperty(f.getValue())); | |
table.getColumns().addAll(column); | |
table.setSelectionModel(new TableView.TableViewSelectionModel<String>(table) { | |
@Override | |
public void select(int row) {} | |
@Override | |
public void select(String obj) {} | |
@Override | |
public ObservableList<TablePosition> getSelectedCells() { | |
return FXCollections.emptyObservableList(); | |
} | |
@Override | |
public boolean isSelected(int row, TableColumn<String, ?> column) { | |
return false; | |
} | |
@Override | |
public void select(int row, TableColumn<String, ?> column) { | |
} | |
@Override | |
public void clearAndSelect(int row, TableColumn<String, ?> column) { | |
} | |
@Override | |
public void clearSelection(int row, TableColumn<String, ?> column) { | |
} | |
@Override | |
public void selectLeftCell() { | |
} | |
@Override | |
public void selectRightCell() { | |
} | |
@Override | |
public void selectAboveCell() { | |
} | |
@Override | |
public void selectBelowCell() { | |
} | |
@Override | |
public void focus(int row) { | |
} | |
}); | |
primaryStage.setScene(new Scene(new StackPane(table))); | |
primaryStage.show(); | |
} | |
public static void main(String[] args) { | |
launch(args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment