Tuesday, 22 November 2016

JavaFX

By,
Prajakta


JavaFX is a set of graphics and media  packages that enables developers to design, create, test, debug, and deploy rich client applications that operate consistently across diverse platforms.
JavaFX developed by Sun Microsystem now acquired by Oracle Corporation.
                             
JavaFX is a family of products for creating rich internet applications (RIAs) with mesmeric media and content across the multiple screens of your life. It includes a runtime and a tools suite that web scripters, designers, and developers can use to quickly build and deliver the next generation of rich Internet applications for desktop, mobile devices, TV, and other platforms. JavaFX tools will offer developer and authoring tools that bridge the gap between user experience design and development logic, giving designers and developers uncommon collaboration opportunities.
The main component of JavaFX technology is JavaFX Script, a declarative language, which is easy to use for visual designers who are familiar with scripting languages. In JavaFX Script, the structure of the programming code similarly matches the actual layout of the GUI, making it easier to understand and maintain.
Sun is not replacing Swing with JavaFX Script. Instead, JavaFX Script makes Swing easier to use. Swing remains one of the best GUI development toolkits of its kind for creating standard GUI components, buttons, listboxes, trees, and tables. Together with Java 2D, Swing makes it easy to customize existing components or to create new custom components to achieve virtually any desired visual effect.
The JavaFX tools suite offers creative solutions for both developers and designers. There is a JavaFX Script plugin with language support for NetBeans IDE. The plugin enables development of JavaFX applications within the cross-platform NetBeans tools suite. In addition, Project Nile is a set of easy-to-use plugins for Adobe Photoshop and Adobe Illustrator that allow designers to export graphical assets to JavaFX applications. This tool simplifies the designer/developer workflow, enabling better collaboration between designers and developers.
If you have existing Java code, you can include it as you build your JavaFX application. Also planned in the future is a tool for visual and graphic designers that will enable them to build JavaFX applications without having to learn JavaFX Script.
Hello World, JavaFX Style
The tool used in this tutorial is NetBeans IDE .

Construct the Application
1. From the File menu, choose New Project.
2. In the JavaFX application category, choose JavaFX Application
3. Then click on NEXT
4. Name the HelloWorld and click Finish

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

public class HelloWorld extends Appllicaton
{
    Public static void main(String [] args)
    {
        launch(args);
    }
    @override
    Public void start(String primaryStage)
    {
        primaryStage.setTitle(“Hello!”);
        Button btn = new Button();
        btn.setText(“Say ‘Hello World’”);
        btn.setOnAction(new EventHandler<ActionEvent>()
        {
            @override
            Public void handle(ActionEvent event)
            {
                System.out.printn(“Hello!”);
            }
        });
        StackPane root = new StackPane();
        root.getChildren().add(btn);
        primaryStage.setScene(new Scene(root, 300, 250));
        primaryStage.show();

    }
}