javafx.scene.control.Button.setStyle()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(332)

本文整理了Java中javafx.scene.control.Button.setStyle()方法的一些代码示例,展示了Button.setStyle()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.setStyle()方法的具体详情如下:
包路径:javafx.scene.control.Button
类名称:Button
方法名:setStyle

Button.setStyle介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

);
final Button button = new Button("I love you", imageView);
button.setStyle("-fx-base: coral;");
button.setContentDisplay(ContentDisplay.TOP);
button.setOnAction(new EventHandler<ActionEvent>() {

代码示例来源:origin: stackoverflow.com

@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", "#"));
    }
  }
}

代码示例来源:origin: io.github.factoryfx/javafxDataEditing

public void setBackGroundColor(Button button, Color color) {
  button.setStyle("-fx-base: " + toCssColor(color) + ";");
}

代码示例来源:origin: stackoverflow.com

@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();
}

代码示例来源:origin: stackoverflow.com

(int) (newColor.getGreen() * 255),
    (int) (newColor.getBlue() * 255));
  button1.setStyle(style);
});

代码示例来源:origin: stackoverflow.com

button.setStyle("-fx-base: mistyrose;");
button.setOnAction(event -> audioClip.play());

代码示例来源:origin: de.jensd/fontawesomefx-common

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;
}

代码示例来源:origin: com.aquafx-project/aquafx

@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);
      }
    }
  }
};

代码示例来源:origin: stackoverflow.com

btBuscaLote.setStyle("-fx-content-display: graphic-only;");

代码示例来源:origin: com.aquafx-project/aquafx

@Override public void handle(Event arg0) {
    if (getSkinnable().isFocused()) {
      setFocusBorder();
    }
    if (getSkinnable().isDefaultButton()) {
      setDefaultButtonAnimation();
      getSkinnable().setStyle(armedButtonStyle);
    }
  }
});

代码示例来源:origin: com.bitplan.gui/com.bitplan.javafx

/**
 * 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);
  }
 });
}

代码示例来源:origin: stackoverflow.com

@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;
 }

代码示例来源:origin: stackoverflow.com

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>() {

代码示例来源:origin: PhoenicisOrg/phoenicis

Button verbButton = new Button(verb.getScriptName());
verbButton.getStyleClass().addAll("toolButton");
verbButton.setStyle("-fx-background-image: url('" + verb.getIcon() + "');");
verbButton.setOnMouseClicked(event -> {
  this.lockAll();

代码示例来源:origin: com.aquafx-project/aquafx

@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();
      }
    }
  }
}

代码示例来源:origin: PhoenicisOrg/phoenicis

/**
 * 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;
  });
}

相关文章

微信公众号

最新文章

更多