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();
}
}
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)