0
我想顯示9個按鈕使用javafx。如何使新的按鈕對象使用for循環,並使用javafx顯示
public class Main extends Application
{
public void start(Stage primaryStage) throws Exception
{
Button[] button = new Button[10];
Pane pane = new Pane();
for(int i=0; i < 9; i++)
{
button[i].setText("hi");
button[i].setText("hi");
button[i].setLayoutX(i*10);
System.out.println(button[i].getText());
pane.getChildren().addAll(button[i]);
}
Scene scene = new Scene(pane);
primaryStage.setScene(scene);
primaryStage.show();
}
按鈕應該如何定位? Button應該對他們說些什麼,能給我們更多的細節嗎? –