图像圆角按钮JavaFX

问题描述:

我正在使用圆角按钮,我想在里面有一个图像。问题是,图像是在中心,而不是在左边,即使叫图像圆角按钮JavaFX

loadButton.setAlignment(Pos.BASELINE_LEFT);

我得到的是上面的按钮,我需要的是下面的按钮。你知道在圆角下展示PNG的方法吗?

enter image description here

final Label response = new Label(); 
    final ImageView imageView = new ImageView(
      new Image("recordbutton.png") 
    ); 
    imageView.setFitHeight(40); 
    imageView.setFitWidth(40); 

    loadButton.setGraphic(imageView); 
    loadButton.setStyle("-fx-base: coral;"); 
    loadButton.setContentDisplay(ContentDisplay.LEFT); 
    loadButton.setStyle(
      "-fx-background-radius: 100em; " + 
        "-fx-min-width: 60px; " + 
        "-fx-min-height: 60px; " + 
        "-fx-max-width: 130px; " + 
        "-fx-max-height: 60px;" 
    ); 

非常感谢!

相反的:

loadButton.setContentDisplay(ContentDisplay.LEFT); 

使用:

loadButton.setAlignment(Pos.CENTER_LEFT);