private void setupTableRowFactory(final ContextMenu contextMenu) { getTableView().setRowFactory(tableView -> { final TableRow<T> tableRow = new TableRow<>(); // update table row color when the item value, the selection or the focus has been changed tableRow.itemProperty().addListener((observable, oldValue, newValue) -> updateTableRowColor(tableRow)); tableRow.selectedProperty().addListener( // (observable, oldValue, newValue) -> updateTableRowColor(tableRow)); getTableView().focusedProperty().addListener( // (observable, oldValue, newValue) -> updateTableRowColor(tableRow)); // bind context menu to row, but only when the row is not empty tableRow.contextMenuProperty().bind( // Bindings.when(tableRow.emptyProperty()) // .then((ContextMenu) null) // .otherwise(contextMenu)); // add listener for double clicks for editing the selected entry (ignore in empty rows) tableRow.setOnMouseClicked(event -> { if (event.getClickCount() > 1 && getSelectedEntryCount() == 1 && !tableRow.isEmpty()) { getEventHandler().onEditEntry(null); } }); return tableRow; }); }
MenuButton(String stringKey) { btn = new FXGLButton(); btn.setAlignment(Pos.CENTER_LEFT); btn.setStyle("-fx-background-color: transparent"); btn.textProperty().bind(localizedStringProperty(stringKey)); p.setMouseTransparent(true); Paint g = new LinearGradient(0, 1, 1, 0.2, true, CycleMethod.NO_CYCLE, new Stop(0.6, Color.color(1, 0.8, 0, 0.34)), new Stop(0.85, Color.color(1, 0.8, 0, 0.74)), new Stop(1, Color.WHITE)); p.fillProperty().bind( Bindings.when(btn.pressedProperty()).then((Paint) Color.color(1, 0.8, 0, 0.75)).otherwise(g) ); p.setStroke(Color.color(0.1, 0.1, 0.1, 0.15)); p.setEffect(new GaussianBlur()); // TODO: hover and/or focused? p.visibleProperty().bind(btn.hoverProperty()); getChildren().addAll(btn, p); }
private ObjectBinding<ApplicationDetailsPanel> createApplicationDetailsPanel() { final ApplicationDetailsPanel applicationPanel = new ApplicationDetailsPanel(scriptInterpreter, filter, selectedApplication); applicationPanel.setShowScriptSource(javaFxSettingsManager.isViewScriptSource()); applicationPanel.setOnClose(this::closeDetailsView); applicationPanel.webEngineStylesheetProperty().bind(themeManager.webEngineStylesheetProperty()); applicationPanel.prefWidthProperty().bind(content.widthProperty().divide(3)); return Bindings.when(Bindings.isNotNull(selectedApplication)) .then(applicationPanel) .otherwise((ApplicationDetailsPanel) null); }