rodude123:
私はJavaFXので働いていると私は、パラメータすなわち、だけでなく、VBoxのように任意のウィンドウをとり、ベースGUI機能を作ることができればと思いまして。
私は国境ペインまたはHBoxのかtilepaneに取るが、私は複数の機能がひとつたくない複数の機能を持つことができます。私もノードにペインをキャストしようとしたがうまくいきませんでした。
私はそれを使用するのはここです
private void menu()
{
VBox root = new VBox();
Label title = new Label("Quiz");
title.setStyle("-fx-font-size: 18px; -fx-font-weight: bold;");
Button btnQuiz = new Button("Quiz");
btnQuiz.setOnAction(event -> quiz());
btnQuiz.setMaxWidth(75);
Button btnCreate = new Button("Create");
btnCreate.setOnAction(event -> create());
btnCreate.setMaxWidth(75);
Button btnQuit = new Button("Quit");
btnQuit.setOnAction(event -> System.exit(0));
btnQuit.setMaxWidth(75);
baseGUI(root, title, btnQuiz, btnCreate, btnQuit);
}
ここbaseGUIコードがあります
private void baseGUI(VBox root, Node... nodes)
{
for (Node node : nodes)
{
root.getChildren().add(node);
}
root.setPadding(new Insets(10));
root.setAlignment(Pos.CENTER);
root.setSpacing(10.00);
Scene scene = new Scene(root, 250, 250);
primaryStage.setScene(scene);
primaryStage.show();
}
最後に、私は、ウィンドウの任意のタイプ、およびノードの別のノードを扱うことができるルートパラメータに取る一つの機能を持っている必要があります。任意の助けてくれてありがとう。
rodude123:
私は最後にこれに管理しますが、誰のためのおかげで助けたこと
/**
* baseGUI function
* Creates a baseGUI function
* @param root
* @param nodes
*/
private void baseGUI(Pane root, Node... nodes)
{
if (root instanceof VBox)
{
((VBox) root).setAlignment(Pos.CENTER);
((VBox) root).setSpacing(10);
((VBox)root).getChildren().add(nodes);
}
root.setPadding(new Insets(10));
Scene scene = new Scene(root, 250, 250);
primaryStage.setScene(scene);
primaryStage.show();
}
将来の参考のために、これは画面のパラメータとペインと出力としてのノードにかかる基地GUI関数です。
更新:
それが今どのペインのために働くように、方法を変更しました