我想 <ImageView> 浮动在 <Button> 的右侧

I want to <ImageView> to float on the right side of the <Button>

我尝试添加图片,但它添加到按钮文本的右侧,而不是最右侧的位置。即我想在右边浮动图像。

final ImageView imageView = new ImageView(
  new Image("Button.png")
);
final Button button = new Button("button", imageView);
button.setStyle("-fx-background-color: white; -fx-border-color: grey; -fx-border-radius: 5;");
button.setContentDisplay(ContentDisplay.RIGHT);

更新 : 这是 link 个我需要的图像和我当前需要改进的按钮设计。 http://imgur.com/jrO0LGD,jGRcxl5

您需要在此处为​​按钮的图形设置自定义布局。使用 StackPane 是我选择的浮动布局(如 css):

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