); final Button button = new Button("I love you", imageView); button.setStyle("-fx-base: coral;"); button.setContentDisplay(ContentDisplay.TOP); button.setOnAction(new EventHandler<ActionEvent>() {
@FXML private void onColorPickerButton() { Button[] buttons = {firstButton, secondButton, thirdButton}; Color color = colorPicker.getValue(); if(color!=null){ for (Button button : buttons) { button.setStyle("-fx-background-color: "+color.toString().replace("0x", "#")); } } }
public void setBackGroundColor(Button button, Color color) { button.setStyle("-fx-base: " + toCssColor(color) + ";"); }
@Override public void start( final Stage primaryStage ) { Text text1 = new Text( "back to home" ); ImageView imageView1 = new ImageView( new Image( "pkg/images1.jpg" ) ); StackPane stackPane1 = new StackPane( text1, imageView1 ); StackPane.setAlignment( text1, Pos.CENTER_LEFT ); StackPane.setAlignment( imageView1, Pos.CENTER_RIGHT ); final Button button1 = new Button( "", stackPane1 ); button1.setStyle( "-fx-background-color: white; -fx-border-color: grey; -fx-border-radius: 5;" ); button1.setMinWidth( 400 ); Text text2 = new Text( "holiday" ); ImageView imageView2 = new ImageView( new Image( "pkg/images2.jpg" ) ); StackPane stackPane2 = new StackPane( text2, imageView2 ); StackPane.setAlignment( text2, Pos.CENTER_LEFT ); StackPane.setAlignment( imageView2, Pos.CENTER_RIGHT ); final Button button2 = new Button( "", stackPane2 ); button2.setStyle( "-fx-background-color: white; -fx-border-color: grey; -fx-border-radius: 5;" ); button2.setMinWidth( 400 ); final Scene scene = new Scene( new VBox( button1, button2 ) ); primaryStage.setScene( scene ); primaryStage.show(); }
(int) (newColor.getGreen() * 255), (int) (newColor.getBlue() * 255)); button1.setStyle(style); });
button.setStyle("-fx-base: mistyrose;"); button.setOnAction(event -> audioClip.play());
public Button createIconButton(GlyphIcons icon, String text, String iconSize, String fontSize, ContentDisplay contentDisplay) { Text label = createIcon(icon, iconSize); Button button = new Button(text); button.setStyle("-fx-font-size: " + fontSize); button.setGraphic(label); button.setContentDisplay(contentDisplay); return button; }
@Override public void changed(ObservableValue<? extends Boolean> observableValue, Boolean oldValue, Boolean newValue) { if (newValue != null) { if (newValue.booleanValue() && getSkinnable().isDefaultButton()) { if (defaultButtonTransition != null && defaultButtonTransition.getStatus() != Status.RUNNING) { setDefaultButtonAnimation(); } } else if (defaultButtonTransition != null && defaultButtonTransition.getStatus() == Status.RUNNING) { setDefaultButtonAnimation(); // button has to look like a usual button again getSkinnable().setStyle(usualButtonStyle); } } } };
btBuscaLote.setStyle("-fx-content-display: graphic-only;");
@Override public void handle(Event arg0) { if (getSkinnable().isFocused()) { setFocusBorder(); } if (getSkinnable().isDefaultButton()) { setDefaultButtonAnimation(); getSkinnable().setStyle(armedButtonStyle); } } });
/** * construct an ImageButton with to Images * * @param pushed * @param unpushed */ public ImageButton(final Image pushed, final Image unpushed) { iv=new ImageView(unpushed); //this.getChildren().add(iv); super.setGraphic(iv); super.setStyle("-fx-background-color: rgba(255, 255, 255, 0);"); setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent evt) { iv.setImage(pushed); } }); setOnMouseReleased(new EventHandler<MouseEvent>() { public void handle(MouseEvent evt) { iv.setImage(unpushed); } }); }
@Override public void start(Stage primaryStage) { // Get the pane for the scene primaryStage.setScene(new Scene(getPane(), 180, 600)); // Setup the stage primaryStage.setTitle("Elevator Buttons"); primaryStage.setResizable(false); primaryStage.show(); } protected Pane getPane() { Pane pane = new VBox(10); pane.setPadding(new Insets(40)); GridPane grid = new GridPane(); for (int i = 0; i < row; i++) { for (int k = 0; k < col; k++) { // Set the button number as text for the button Button button = new Button(Integer.toString((row * col - 2 * i - 1) + k)); button.setPrefWidth(100); button.setStyle("-fx-font: 22 arial; -fx-base: LightGray"); // Add the button to the pane and set the handler grid.add(button, k, i); button.setOnAction(buttonHandler); } } return grid; }
final ImageView imageView = new ImageView(resampledImage); final Button button = new Button("I love you", imageView); button.setStyle("-fx-base: coral;"); button.setContentDisplay(ContentDisplay.TOP); button.setOnAction(new EventHandler<ActionEvent>() {
Button verbButton = new Button(verb.getScriptName()); verbButton.getStyleClass().addAll("toolButton"); verbButton.setStyle("-fx-background-image: url('" + verb.getIcon() + "');"); verbButton.setOnMouseClicked(event -> { this.lockAll();
@Override protected void handleControlPropertyChanged(String p) { super.handleControlPropertyChanged(p); if (p == "HOVER") { if (getSkinnable().isDefaultButton() && getSkinnable().isPressed() && getSkinnable().isHover()) { getSkinnable().setStyle(armedButtonStyle); } else if (getSkinnable().isDefaultButton() && getSkinnable().isPressed() && !getSkinnable().isHover()) { getSkinnable().setStyle(usualButtonStyle); } } if (p == "FOCUSED") { if (getSkinnable().isFocused()) { setFocusBorder(); } else if (!getSkinnable().isFocused() || getSkinnable().isDisable()) { setDropShadow(); } } if (p == "DEFAULT_BUTTON") { setDefaultButtonAnimation(); } if (p == "DISABLED") { if (getSkinnable().isDefaultButton()) { if (getSkinnable().isDisabled() && defaultButtonTransition != null && defaultButtonTransition.getStatus() != Status.RUNNING) { defaultButtonTransition.stop(); } else { setDefaultButtonAnimation(); } } } }
/** * Constructor * * @param control The control belonging to the skin */ public ContainerEngineToolsPanelSkin(ContainerEngineToolsPanel control) { super(control); // map the tool scripts to a tool button this.toolButtons = new MappedList<>(control.getEngineToolScripts(), tool -> { final Button toolButton = new Button(tool.getScriptName()); toolButton.getStyleClass().addAll("toolButton"); toolButton.setStyle("-fx-background-image: url('" + tool.getIcon() + "');"); toolButton.disableProperty().bind(getControl().lockToolsProperty()); toolButton.setOnMouseClicked(event -> { getControl().setLockTools(true); final ContainerDTO container = getControl().getContainer(); // TODO: find a better way to get the engine ID getControl().getEngineToolsManager().runTool(container.getEngine().toLowerCase(), container.getName(), tool.getId(), () -> getControl().setLockTools(false), e -> Platform.runLater(() -> { final ErrorDialog errorDialog = ErrorDialog.builder() .withMessage(tr("Error")) .withException(e) .build(); errorDialog.showAndWait(); })); }); return toolButton; }); }