Hello. I am trying a JavaFX code on eclipse but I am having problems with the layout.setCenter(button); line. Everytime I run it, it gives me the error "The method setCenter(Node) in the tupe BorderPane is not applicable for the arguments (Button)". I don't know why this error is popping up because I believe I installed the JavaFX SDK and plugin correctly. Is there anything wrong with my VM arguments. Please let me know as I would appreciate the help. Thanks. Here is the code, I bolded the line that is giving me the error: import java.awt.Button; import javafx.application.Application; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; public class Main extends Application { private BorderPane layout; private Scene scene; private Object Node; public static void main (String[] args) { launch(args); } @Override public void start(Stage window) throws Exception { // TODO Auto-generated method stub layout = new BorderPane(); scene = new Scene(layout, 450, 80); Button button = new Button("Click Me"); layout.setCenter(button); window.setScene(scene); window.show(); } }
Hello. I am trying a JavaFX code on eclipse but I am having problems with the layout.setCenter(button); line. Everytime I run it, it gives me the error "The method setCenter(Node) in the tupe BorderPane is not applicable for the arguments (Button)". I don't know why this error is popping up because I believe I installed the JavaFX SDK and plugin correctly. Is there anything wrong with my VM arguments. Please let me know as I would appreciate the help. Thanks.
Here is the code, I bolded the line that is giving me the error:
import java.awt.Button;
import javafx.application.Application;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class Main extends Application {
private BorderPane layout;
private Scene scene;
private Object Node;
public static void main (String[] args) {
launch(args);
}
@Override
public void start(Stage window) throws Exception {
// TODO Auto-generated method stub
layout = new BorderPane();
scene = new Scene(layout, 450, 80);
Button button = new Button("Click Me");
layout.setCenter(button);
window.setScene(scene);
window.show();
}
}
Step by step
Solved in 4 steps with 2 images