Example usage for javafx.scene.control TableView focusModelProperty

List of usage examples for javafx.scene.control TableView focusModelProperty

Introduction

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

Prototype

public final ObjectProperty<TableViewFocusModel<S>> focusModelProperty() 

Source Link

Document

Represents the currently-installed TableViewFocusModel for this TableView.

Usage

From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java

@FXML
void onTableClicked(MouseEvent event) {
    if (event.getClickCount() != 2)
        return;//w  w  w . java2 s  .  c o m
    TableView tableView = ((TableView) event.getSource());
    TableView.TableViewFocusModel focusModel = (TableView.TableViewFocusModel) tableView.focusModelProperty()
            .getValue();
    TablePosition position = focusModel.getFocusedCell();
    if (position.getTableColumn() == null)
        return;
    ObservableValue value = position.getTableColumn().getCellObservableValue(position.getRow());
    String valueStr = value.getValue().toString();
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setHeaderText(String.format("Value at ID:%d  %s",
            ((LIMSData) tableView.getItems().get(position.getRow())).getId(),
            position.getTableColumn().getText()));
    if (valueStr.length() > 300)
        alert.setContentText(valueStr.substring(0, 300) + "...");
    else
        alert.setContentText(valueStr);

    TextArea textArea = new TextArea(valueStr);
    textArea.setEditable(false);
    alert.getDialogPane().setExpandableContent(textArea);

    event.consume();
    alert.show();
}