Hi,
I am new to JavaFX. In my following code, the getHBox() which is a non-static method is accessed without creating an object.
public class Main extends Application {
public void start(Stage primaryStage) {
//Main m = new Main();
try {
BorderPane rootPane = new BorderPane();
rootPane.setTop(getHBox());
//rootPane.setTop(m.getHBox());
Scene scene = new Scene(rootPane,400,400);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public HBox getHBox()
{
HBox hb = new HBox(15);
hb.getChildren().add(new Button("Press"));
return hb;
}
public static void main(String[] args) {
launch(args);
}
}
Now I have looked at the answers in the web. Guys are talking something about class member. How is getHBox() method different from any other method? Please provide some explanation or direct me to an appropriate tutorial.
Bye.