Ich versuche ein Button in eine Zelle vom GridPane zu legen, aber es funktioniert nicht.
Fehlermeldung:The method setConstraints(Node, int, int) in the type GridPane is not applicable for the arguments (Button, int, int)
Beim TextField klappt es aber, bei Buttons scheint es nicht zu funktionieren.
Java:
import java.awt.Button;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.TilePane;
import javafx.stage.Stage;
public class Main extends Application {
public Button b1;
public static void main(String[] args) {
launch(args);
}
public void start(Stage window) {
window.setTitle("Taschenrechner");
window.setMaxHeight(400);
window.setMaxWidth(400);
TextField textfield = new TextField();
b1 = new Button("1");
GridPane gp = new GridPane();
gp.setPadding(new Insets(10,10,10,10));
GridPane.setConstraints(b1,0,0);
GridPane.setConstraints(textfield,0,1);
Scene scene = new Scene(gp);
window.setScene(scene);
window.show();
}
}
Fehlermeldung:The method setConstraints(Node, int, int) in the type GridPane is not applicable for the arguments (Button, int, int)
Beim TextField klappt es aber, bei Buttons scheint es nicht zu funktionieren.