[HELLO WORLD] Your First Program In JavaFX

As I have already written about how to start programming with JavaFX in NetBeans , We may now proceed to the next step in programming. That is, your first program in JavaFx. I hope that you have already installed JavaFx in your PC. If not,you may read the previous section here about how to start programming with JavaFx in NetBeans.You can follow the installation process there and again come back.

Generally in almost all of the programming languages,the first program you learned is the "Hello World" program.Since the basic of all programming language is to learn the hello world program , i am going to teach you the same program using JavaFx.

Here, I have posted the Source code for the "Hello World" Program :-


package test;


import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.stage.Stage;


/**
 *
 * @author Deepesh Khanal
 * 
 */
public  class hello extends Application
{
    
    public static void main(String[] args) 
    {
        launch(args);
        
    }        
      
    @Override
    public void start(Stage stage) throws Exception 
    {      
        Group root = new Group();
        Scene scene = new Scene(root,200,100);
        root.getChildren().add(new Text(60,50,"Hello World."));
        stage.setScene(scene);
        stage.show();  
    }
    
            
}


All you need to do is to copy the above code and run it. Be careful to change the name of class and the package name in the above code.You have to change the package 'test' to your package name and the class 'hello' to your class name.I have underlined the things to change in the above code.so it will be easy for you.


Here is the Screenshot of the output after you run it :-


                                                                      Hope this may help you.....
                                                                              RefreshIt   


[HELLO WORLD] Your First Program In JavaFX [HELLO WORLD] Your First Program In JavaFX Reviewed by RefreshIt on 10:13:00 PM Rating: 5

No comments:

Powered by Blogger.