Java Code Examples for javafx.scene.control.Button#setVisible()
The following examples show how to use
javafx.scene.control.Button#setVisible() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SearchBox.java From oim-fx with MIT License | 6 votes |
public SearchBox() { String searchBoxCss = SearchBox.class.getResource("/common/css/searchbox.css").toExternalForm(); getStylesheets().add(searchBoxCss); setId("SearchBox"); getStyleClass().add("search-box"); setMinHeight(24); // setPrefSize(200, 24); setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE); textField = new TextField(); textField.setPromptText("查找"); clearButton = new Button(); clearButton.setVisible(false); getChildren().addAll(textField, clearButton); clearButton.setOnAction((ActionEvent actionEvent) -> { textField.setText(""); textField.requestFocus(); }); textField.textProperty().addListener((ObservableValue<? extends String> observable, String oldValue, String newValue) -> { clearButton.setVisible(textField.getText().length() != 0); }); }
Example 2
Source File: SearchBoxSample.java From marathonv5 with Apache License 2.0 | 6 votes |
public SearchBox() { setId("SearchBox"); getStyleClass().add("search-box"); setMinHeight(24); setPrefSize(200, 24); setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE); textBox = new TextField(); textBox.setPromptText("Search"); clearButton = new Button(); clearButton.setVisible(false); getChildren().addAll(textBox, clearButton); clearButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { textBox.setText(""); textBox.requestFocus(); } }); textBox.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { clearButton.setVisible(textBox.getText().length() != 0); } }); }
Example 3
Source File: SearchBoxSample.java From marathonv5 with Apache License 2.0 | 6 votes |
public SearchBox() { setId("SearchBox"); getStyleClass().add("search-box"); setMinHeight(24); setPrefSize(200, 24); setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE); textBox = new TextField(); textBox.setPromptText("Search"); clearButton = new Button(); clearButton.setVisible(false); getChildren().addAll(textBox, clearButton); clearButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { textBox.setText(""); textBox.requestFocus(); } }); textBox.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { clearButton.setVisible(textBox.getText().length() != 0); } }); }
Example 4
Source File: MainNode.java From helloiot with GNU General Public License v3.0 | 6 votes |
public void setToolbarButton(EventHandler<ActionEvent> backevent, Node graphic, String text) { Label l = new Label(); l.setContentDisplay(ContentDisplay.GRAPHIC_ONLY); l.setAlignment(Pos.CENTER); l.setGraphic(graphic); l.setPrefSize(45.0, 40.0); backbutton = new Button(text, l); backbutton.setAlignment(Pos.BASELINE_LEFT); backbutton.setMaxWidth(Double.MAX_VALUE); backbutton.setFocusTraversable(false); backbutton.setMnemonicParsing(false); backbutton.getStyleClass().add("menubutton"); backbutton.setOnAction(backevent); backbutton.setVisible(backevent != null); }
Example 5
Source File: GameBoardView.java From metastone with GNU General Public License v2.0 | 6 votes |
private void enableSummonTargets(final HumanTargetOptions targetOptions) { int playerId = targetOptions.getPlayerId(); GameContext context = targetOptions.getContext(); for (final GameAction action : targetOptions.getActionGroup().getActionsInGroup()) { Entity target = context.resolveSingleTarget(action.getTargetKey()); GameToken token = getToken(target); Button summonHelper = playerId == 0 ? summonHelperMap1.get(token) : summonHelperMap2.get(token); summonHelper.setVisible(true); summonHelper.setManaged(true); EventHandler<ActionEvent> clickedHander = new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { disableTargetSelection(); targetOptions.getActionSelectionListener().onActionSelected(action); } }; summonHelper.setOnAction(clickedHander); } }
Example 6
Source File: LayoutHelpers.java From houdoku with MIT License | 5 votes |
/** * Set whether all Button children of the given Parent are visible. * * @param parent the parent node * @param visible whether the buttons should be visible */ public static void setChildButtonVisible(Parent parent, boolean visible) { for (Node child : parent.getChildrenUnmodifiable()) { if (child instanceof Button) { Button button = (Button) child; button.setVisible(visible); button.setManaged(visible); } else if (child instanceof Parent) { setChildButtonVisible((Parent) child, visible); } } }
Example 7
Source File: GameBoardView.java From metastone with GNU General Public License v2.0 | 5 votes |
private Button createSummonHelper() { ImageView icon = new ImageView(IconFactory.getSummonHelper()); icon.setFitWidth(32); icon.setFitHeight(32); Button helper = new Button("", icon); helper.setStyle("-fx-padding: 2 2 2 2;"); helper.setVisible(false); helper.setManaged(false); return helper; }
Example 8
Source File: ActionInputPane.java From constellation with Apache License 2.0 | 4 votes |
public ActionInputPane(final PluginParameter<?> parameter) { field = new Button(); String label = parameter.getStringValue(); if (label == null || label.isEmpty()) { label = parameter.getName(); } field.setText(label); String icon = parameter.getIcon(); if (icon != null) { ImageView img = new ImageView(icon); field.setGraphic(img); } field.setManaged(parameter.isVisible()); field.setVisible(parameter.isVisible()); this.setManaged(parameter.isVisible()); this.setVisible(parameter.isVisible()); field.setOnAction(event -> { // Set a new Object every time so the change event fires. // parameter.setObjectValue(new Object()); parameter.fireNoChange(); }); parameter.addListener((final PluginParameter<?> pluginParameter, final ParameterChange change) -> { Platform.runLater(() -> { switch (change) { case ENABLED: field.setDisable(!pluginParameter.isEnabled()); break; case VISIBLE: field.setManaged(parameter.isVisible()); field.setVisible(parameter.isVisible()); this.setVisible(parameter.isVisible()); this.setManaged(parameter.isVisible()); break; default: LOGGER.log(Level.FINE, "ignoring parameter change type {0}.", change); break; } }); }); getChildren().add(field); }