How to seperate a JavaFX Appliciation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to seperate a JavaFX Appliciation

fhs14647
Hello everyone
I want to seperate a JavaFX project to model, view and controller.
I use netbeans when creating a JavaFX application. In the end it looks like this


Code:
package at.wueschn.www;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) {
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
            }
        });

        StackPane root = new StackPane();
        root.getChildren().add(btn);

        Scene scene = new Scene(root, 300, 250);

        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }

}




But I want the code seperate, an own GUI, own logic and a Main class just to start the application (I want 3 seperate classes).
But I am not able to solve this problem. Maybe you can help me ...

Thanks a lot
fhs14647 [Rolling Eyes]




Reply | Threaded
Open this post in threaded view
|

Re: How to seperate a JavaFX Appliciation

geertjan.wielenga@oracle.com

You’re encouraged to move to the Apache NetBeans mailing lists as soon as possible, ask your questions and discuss any concerns, etc, there and to not write to the @netbeans.org mailing lists anymore.

https://cwiki.apache.org/confluence/display/NETBEANS/How+to+Participate



Geertjan Wielenga | Principal Product Manager
Phone: +31620320056 | 
Oracle Developer Tools

ORACLE Netherlands | Hertogswetering 163-167 | 3543 AS Utrecht | Netherlands


Oracle is committed to developing practices and products that help protect the environment

On 28 Nov 2017, at 20:31, fhs14647 <[hidden email]> wrote:

Hello everyone
I want to seperate a JavaFX project to model, view and controller.
I use netbeans when creating a JavaFX application. In the end it looks like this


Code:
package at.wueschn.www;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class Main extends Application {

   @Override
   public void start(Stage primaryStage) {
       Button btn = new Button();
       btn.setText("Say 'Hello World'");
       btn.setOnAction(new EventHandler<ActionEvent>() {

           @Override
           public void handle(ActionEvent event) {
               System.out.println("Hello World!");
           }
       });

       StackPane root = new StackPane();
       root.getChildren().add(btn);

       Scene scene = new Scene(root, 300, 250);

       primaryStage.setTitle("Hello World!");
       primaryStage.setScene(scene);
       primaryStage.show();
   }

   public static void main(String[] args) {
       launch(args);
   }

}




But I want the code seperate, an own GUI, own logic and a Main class just to start the application (I want 3 seperate classes).
But I am not able to solve this problem. Maybe you can help me ...

Thanks a lot
fhs14647 [Rolling Eyes]