int buttonSize = 70; Button button = new Button("A"); button.setMinSize(buttonSize, buttonSize); button.setPrefSize(buttonSize, buttonSize); button.setMaxSize(buttonSize, buttonSize); button.setStyle(String.format("-fx-font-size: %dpx;", (int)(0.45 * buttonSize)));
Group svg = new Group( createPath("M0,0h100v100h-100z", "red", "darkred"), createPath("M20,20h60v60h-60z", "blue", "darkblue") ); Bounds bounds = svg.getBoundsInParent(); double scale = Math.min(20/bounds.getWidth(), 20 / bounds.getHeight()); svg.setScaleX(scale); svg.setScaleY(scale); Button btn = new Button(); btn.setGraphic(svg); btn.setMaxSize(30, 30); btn.setMinSize(30, 30); btn.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
VBox vBox = new VBox(); Button button = new Button("Click me"); button.setMinSize(50.0, 50.0); button.setOnMouseReleased(new EventHandler<MouseEvent>() { @Override button_2.setMinSize(50.0, 50.0); button_2.setOnMouseReleased(new EventHandler<MouseEvent>() { @Override
left.setMinSize(Button.USE_PREF_SIZE, Button.USE_PREF_SIZE); final Pane spacer = new Pane(); HBox.setHgrow(spacer, Priority.ALWAYS); spacer.setMinSize(10, 1); final Button right = new Button("Right"); right.setMinSize(Button.USE_PREF_SIZE, Button.USE_PREF_SIZE);
b.setMinSize(80, 80); pane.getChildren().add(b); b.setOnAction((e) -> doSomething(b.getText()));
apply.setMinSize(Button.USE_PREF_SIZE, Button.USE_PREF_SIZE); apply.setDefaultButton(true); apply.setOnAction(event -> label.setStyle(style.getText()));
private Popup addExitPopup(){ Popup exitPopup = new Popup(); //Exit Panel VBox exitBox = new VBox(); exitBox.setPadding(new Insets(10)); Button exitPaneExit = new Button(); exitPaneExit.setText("Return"); exitPaneExit.setMinSize(75.0, 30.0); exitPaneExit.setOnAction(e -> { exitPopup.hide(); }); Button exitButton = new Button(); exitButton.setText("Exit"); exitButton.setMinSize(75.0, 30.0); exitButton.setOnAction(e -> { System.exit(0); }); exitBox.getChildren().addAll(exitPaneExit,exitButton); exitBox.setVisible(true); exitPopup.setAutoHide(true); exitPopup.getContent().add(exitBox); return exitPopup; }
buttonWithGraphics.setMinSize(MIN_BUTTON_SIZE, MIN_BUTTON_SIZE);