テキスト付きのこのダイアログがあります。
public class DX57DC extends Application
{
public static void main(String[] args)
{
Application.launch(args);
}
@Override
public void start(Stage primaryStage) throws URISyntaxException, MalformedURLException
{
// Image
ImageView iv = new ImageView(getClass().getResource("system-help.png").toExternalForm());
// Text
Text t = new Text();
t.setTextAlignment(TextAlignment.LEFT);
t.setText("Do you want to quit?");
HBox thbox = new HBox(8); // spacing = 8
thbox.getChildren().addAll(thbox);
thbox.setAlignment(Pos.CENTER);
// Buttons
Button btnYes = new Button("Yes");
Button btnNo = new Button("No");
btnYes.setStyle("-fx-background-color:\n"
+ " rgba(0,0,0,0.08),\n"
+ " linear-gradient(#9a9a9a, #909090),\n"
+ " linear-gradient(white 0%, #f3f3f3 50%, #ececec 51%, #f2f2f2 100%);\n"
+ " -fx-background-insets: 0 0 -1 0,0,1;\n"
+ " -fx-background-radius: 5,5,4;\n"
+ " -fx-padding: 10 26 10 26;\n"
+ " -fx-text-fill: #242d35;\n"
+ " -fx-font-size: 14px;");
btnNo.setStyle("-fx-background-color:\n"
+ " rgba(0,0,0,0.08),\n"
+ " linear-gradient(#9a9a9a, #909090),\n"
+ " linear-gradient(white 0%, #f3f3f3 50%, #ececec 51%, #f2f2f2 100%);\n"
+ " -fx-background-insets: 0 0 -1 0,0,1;\n"
+ " -fx-background-radius: 5,5,4;\n"
+ " -fx-padding: 10 26 10 26;\n"
+ " -fx-text-fill: #242d35;\n"
+ " -fx-font-size: 14px;");
// Image layout
VBox vbox = new VBox(7);
vbox.getChildren().addAll(iv);
vbox.setAlignment(Pos.CENTER);
// Buttons layout
HBox hbox = new HBox(8); // spacing = 8
//hbox.setStyle("-fx-padding: 10; -fx-font-size: 10pt;");
hbox.getChildren().addAll(btnYes, btnNo);
hbox.setAlignment(Pos.CENTER);
BorderPane bp = new BorderPane();
bp.setStyle("-fx-background-color: linear-gradient(#ffffff,#f3f3f4);\n"
+ " -fx-border-width: 1 1 1 1;\n"
+ " -fx-border-color: #b4b4b4 transparent #b4b4b4 transparent;\n"
+ " -fx-font-size: 1.083333em;\n"
+ " -fx-text-fill: #292929;");
bp.setPadding(new Insets(15, 20, 15, 20));
//Button btnTop = new Button("Top");
bp.setTop(null);
//Button btnLeft = new Button("Left");
bp.setLeft(vbox);
//Button btnCenter = new Button("Center");
bp.setCenter(t);
//Button btnRight = new Button("Right");
bp.setRight(null);
//Button btnBottom = new Button("Bottom");
bp.setBottom(hbox);
Scene scene = new Scene(bp, 500, 160);
primaryStage.setScene(scene);
primaryStage.setTitle("Question Dialog");
primaryStage.show();
}
}
テキストを画像に近づける方法を教えてください。これで、テキストが境界ペインの中央に配置されました。