Example usage for javafx.scene.control TableRow TableRow

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

Introduction

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

Prototype

public TableRow() 

Source Link

Document

Constructs a default TableRow instance with a style class of 'table-row-cell'

Usage

From source file:com.github.vatbub.tictactoe.view.Main.java

@FXML
// This method is called by the FXMLLoader when initialization is complete
void initialize() {
    // modify the default exception handler to show a good error message on every uncaught exception
    final Thread.UncaughtExceptionHandler currentUncaughtExceptionHandler = Thread
            .getDefaultUncaughtExceptionHandler();
    Thread.setDefaultUncaughtExceptionHandler((thread, exception) -> {
        if (currentUncaughtExceptionHandler != null) {
            // execute current handler as we only want to append it
            currentUncaughtExceptionHandler.uncaughtException(thread, exception);
        }/*from   w  ww  . j  a v a 2 s . com*/
        Platform.runLater(() -> new ExceptionAlert(exception).showAndWait());
    });

    opponentsTurnHBox.heightProperty()
            .addListener((observable, oldValue, newValue) -> updateOpponentsTurnHBox(false));

    aiLevelLabelClipRectangle = new Rectangle(0, 0, 0, 0);
    aiLevelLabelClipRectangle.setEffect(new MotionBlur(0, 10));
    aiLevelLabelPane.setClip(aiLevelLabelClipRectangle);
    aiLevelLabelClipRectangle.heightProperty().bind(aiLevelLabelPane.heightProperty());
    aiLevelLabelPane.widthProperty().addListener((observable, oldValue, newValue) -> updateAILevelLabel(true));

    Rectangle menuSubBoxClipRectangle = new Rectangle(0, 0, 0, 0);
    menuSubBox.setClip(menuSubBoxClipRectangle);
    menuSubBoxClipRectangle.heightProperty().bind(menuSubBox.heightProperty());
    menuSubBoxClipRectangle.widthProperty().bind(menuSubBox.widthProperty());

    Rectangle playOnlineClipRectangle = new Rectangle(0, 0, 0, 0);
    playOnlineClipAnchorPane.setClip(playOnlineClipRectangle);
    playOnlineClipRectangle.heightProperty().bind(playOnlineClipAnchorPane.heightProperty());
    playOnlineClipRectangle.widthProperty().bind(playOnlineClipAnchorPane.widthProperty());

    player1SetSampleName();
    player2SetSampleName();

    gameTable.heightProperty()
            .addListener((observable, oldValue, newValue) -> refreshedNodes.refreshAll(gameTable.getWidth(),
                    oldValue.doubleValue(), gameTable.getWidth(), newValue.doubleValue()));
    gameTable.widthProperty()
            .addListener((observable, oldValue, newValue) -> refreshedNodes.refreshAll(oldValue.doubleValue(),
                    gameTable.getHeight(), newValue.doubleValue(), gameTable.getHeight()));

    player1AIToggle.selectedProperty().addListener((observable, oldValue, newValue) -> {
        showHideAILevelSlider(newValue, player2AIToggle.isSelected());
        player1SetSampleName();
    });
    player2AIToggle.selectedProperty().addListener((observable, oldValue, newValue) -> {
        showHideAILevelSlider(player1AIToggle.isSelected(), newValue);
        player2SetSampleName();
    });

    gameTable.setSelectionModel(null);
    gameTable.heightProperty().addListener((observable, oldValue, newValue) -> {
        Pane header = (Pane) gameTable.lookup("TableHeaderRow");
        if (header.isVisible()) {
            header.setMaxHeight(0);
            header.setMinHeight(0);
            header.setPrefHeight(0);
            header.setVisible(false);
        }
        renderRows();
    });
    gameTable.setRowFactory(param -> {
        TableRow<Row> row = new TableRow<>();
        row.styleProperty().bind(style);

        if (rowFont == null) {
            rowFont = new SimpleObjectProperty<>();
            rowFont.bind(row.fontProperty());
        }

        return row;
    });

    looseImage.fitHeightProperty().bind(looserPane.heightProperty());
    looseImage.fitWidthProperty().bind(looserPane.widthProperty());
    looseImage.fitHeightProperty().addListener((observable, oldValue, newValue) -> reloadImage(looseImage,
            getClass().getResource("loose.png").toString(), looseImage.getFitWidth(), newValue.doubleValue()));
    looseImage.fitWidthProperty().addListener((observable, oldValue, newValue) -> reloadImage(looseImage,
            getClass().getResource("loose.png").toString(), newValue.doubleValue(), looseImage.getFitWidth()));

    confetti.fitHeightProperty().bind(winPane.heightProperty());
    confetti.fitWidthProperty().bind(winPane.widthProperty());
    confetti.fitHeightProperty().addListener((observable, oldValue, newValue) -> reloadImage(confetti,
            getClass().getResource("confetti.png").toString(), confetti.getFitWidth(), newValue.doubleValue()));
    confetti.fitWidthProperty().addListener((observable, oldValue, newValue) -> reloadImage(confetti,
            getClass().getResource("confetti.png").toString(), newValue.doubleValue(), confetti.getFitWidth()));

    aiLevelSlider.valueProperty().addListener((observable, oldValue, newValue) -> updateAILevelLabel());

    playOnlineHyperlink.widthProperty().addListener((observable, oldValue, newValue) -> {
        if (playOnlineAnchorPane.isVisible()) {
            setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true);
        }
    });
    playOnlineHyperlink.heightProperty().addListener((observable, oldValue, newValue) -> {
        if (playOnlineAnchorPane.isVisible()) {
            setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true);
        }
    });
    playOnlineHyperlink.textProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue.equals(oldValue)) {
            if (newValue.contains("ff")) {
                setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true, 1);
            } else {
                setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true, -1);
            }
        }
    });

    // Kunami code
    root.setOnKeyPressed(event -> {
        if (KunamiCode.isCompleted(event.getCode())) {
            if (root.getEffect() != null && root.getEffect() instanceof Blend) {
                BlendMode currentMode = ((Blend) root.getEffect()).getMode();
                BlendMode nextMode;
                if (currentMode == BlendMode.values()[BlendMode.values().length - 1]) {
                    nextMode = BlendMode.values()[0];
                } else {
                    nextMode = BlendMode.values()[Arrays.asList(BlendMode.values()).indexOf(currentMode) + 1];
                }
                ((Blend) root.getEffect()).setMode(nextMode);
            } else {
                root.setEffect(new Blend(BlendMode.EXCLUSION));
            }
        }
    });

    // prompt text of the my username field in the online multiplayer menu
    onlineMyUsername.promptTextProperty().bind(player1Name.promptTextProperty());
    onlineMyUsername.textProperty().bindBidirectional(player1Name.textProperty());

    setAccessibleTextsForNodesThatDoNotChange();
    updateAccessibleTexts();

    initBoard();
    initNewGame();
}

From source file:com.ggvaidya.scinames.dataset.DatasetSceneController.java

@SuppressWarnings("unchecked")
private void initAdditionalData() {
    // Resize to fit columns, as per https://stackoverflow.com/a/22488513/27310
    additionalDataTableView.setColumnResizePolicy((param) -> true);

    // Set up additional data objects.
    additionalDataTableView.setRowFactory(table -> {
        @SuppressWarnings("rawtypes")
        TableRow row = new TableRow<>();

        row.setOnMouseClicked(event -> {
            if (row.isEmpty())
                return;
            Object item = row.getItem();

            if (event.getClickCount() == 2) {
                // Try opening the detailed view on this item -- if we can.
                datasetView.getProjectView().openDetailedView(item);
            }/* w  w w.ja  va  2s . c  om*/
        });

        return row;
    });
    additionalDataTableView.setItems(new SortedList<>(tableItems));

    // Set up events.
    additionalDataCombobox.getSelectionModel().selectedItemProperty()
            .addListener((Observable o) -> additionalDataUpdateList());
    additionalListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    additionalListView.getSelectionModel().selectedItemProperty()
            .addListener((Observable o) -> additionalDataUpdateTable());

    additionalDataCombobox.getSelectionModel().select(0);

    // When the change is changed, select an item.
    changesTableView.getSelectionModel().getSelectedItems()
            .addListener((ListChangeListener<Change>) c -> additionalDataUpdateList());
}

From source file:com.ggvaidya.scinames.dataset.BinomialChangesSceneController.java

@SuppressWarnings("unchecked")
private void initAdditionalData() {
    // Resize to fit columns, as per https://stackoverflow.com/a/22488513/27310
    additionalDataTableView.setColumnResizePolicy((param) -> true);

    // Set up additional data objects.
    additionalDataTableView.setRowFactory(table -> {
        @SuppressWarnings("rawtypes")
        TableRow row = new TableRow<>();

        row.setOnMouseClicked(event -> {
            if (row.isEmpty())
                return;
            Object item = row.getItem();

            if (event.getClickCount() == 2) {
                // Try opening the detailed view on this item -- if we can.
                binomialChangesView.getProjectView().openDetailedView(item);
            }/*from ww w  . java  2s. c o m*/
        });

        return row;
    });
    additionalDataTableView.setItems(new SortedList<>(tableItems));

    // Set up events.
    additionalDataCombobox.getSelectionModel().selectedItemProperty()
            .addListener((Observable o) -> additionalDataUpdateList());
    additionalListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    additionalListView.getSelectionModel().selectedItemProperty()
            .addListener((Observable o) -> additionalDataUpdateTable());

    additionalDataCombobox.getSelectionModel().select(0);

    // When the change is changed, select an item.
    changesTableView.getSelectionModel().getSelectedItems()
            .addListener((ListChangeListener<Change>) c -> additionalDataUpdateList());
}