Thursday, 16 July 2015

How To Create HelloWord Application In JavaFx Using Netbeans



In today's world most of the applications are created using javaFx because of it's features and javaFx is intended to replace swing.In this tutorial we are going to create a simple hello word application in javaFx using NetbeansIDE. To follow this tutorial you must have.

  • Netbeans 7.3 or more recent.
  • jdk 1.7 or more recent.
First open netbeans then choose File>>New project or simpy press cntrl+shift+N a new wizard will open like this.




then select JavaFx>> JavaFxApplication and click on next button to proceed.after clicking next button new wizard will open like this 




 Fill project name main class name which you want to be set for your project ide will automatically generate javaFx enabled platform if you can change it.Your javaFx application is successfully created in project window at left hand side to open it press double click on it but it will contain default program of helloword. paste following  code in editor 


CODE TO BE PASTE:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class helloword extends Application 
{
@Override


public void start(Stage primaryStage)
 {

Label l1 = new Label("Helloword In Java FX");
StackPane root = new StackPane();
root.getChildren().add(l1);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();

}

public static void main(String[] args) {

launch(args);

}


}


press the run button to compile and run your program as shown in picture 


It will create a following output now you are able to design your own javaFx application using netbeans IDE

OUTPUT:



No comments:

Post a Comment