Quick Contact

    Hibernate

    JavaFXAPI

    In order to build rich client applications, a library known as JavaFX is used which offers an API for creating, testing, debugging and deploying GUI applications that run on nearly all devices that have the support of Java. That is, it operates in a consistent manner across all platforms. Moreover, these application programming interfaces (API) helps in such a way that it acts as a friendly alternative for JVM languages (Java Virtual Machine) languages like Scala as well as JRuby. Also, it accesses several capabilities of the native system and help in connection to middleware applications which are server-based.

    Packages in JavaFX API

    The important JavaFX API packages include:

    • javafx.animation:

      A set of classes will be provided that is for transition-related animations.

    • javafx.application:

      Application life-cycle classes of the package will be provided.

    • javafx.beans:

      Interfaces that explain the observability generic form is explained in this package.

    • javafx.beans.binding:

      Binding characteristics are explained in this package.

    • javafx.beans.property:

      Read-only and writable properties along with numerous implementations are provided in this package.

    • javafx.beans.value:

      ObservableValue interface and WritableValue interface, along with all the sub-interfaces, are provided in this package.

    • javafx.collections:

      All the JavaFX collections and their utilities are available in this package.

    • javafx.concurrent:

      A set of classes will be provided for the javafx.task.

    • javafx.css:

      An API that makes the properties stylable with the help of CSS and supports pseudo-class state is provided in this package.

    • javafx.embed.swing:

      A set of classes that helps in using JavaFX within the swing applications is provided.

    • javafx.embed.swt:

      A set of classes that helps in using JavaFX within the SWT applications is provided.

    • javafx.event:

      A basic framework is provided for the FX events, their delivery as well as handling.

    • javafx.fxml:

      In order to load a hierarchy of object from markup, this package contains all the classes.

    • javafx.geometry:

      This package consists of 2D classes set that define as well as perform operations on objects that relate to 2-D geometry.

    • javafx.print:

      This package offers the JavaFX printing API public classes.

    • javafx.scene:

      This package contains the base classes’ core set for the scene graph API in JavaFX.

    • javafx.scene.canvas:

      This package offers a class set for canvas which is a rendering API’s immediate mode style.

    • javafx.scene.chart:

      This offers several chart components, which is very useful for data visualization.

    • javafx.scene.control:

      User interface controls in JavaFX are the specialized nodes which are available in the scene graph of JavaFX. It is especially appropriate for reusing several application contexts.

    • javafx.scene.effect:

      This package offers different classes for the attachment of graphical filter effects to the nodes of the JavaFX scene graph.

    Examples of JavaFX API

    Example #1

    JavaFX program that displays a background color with the help of API packages.

    Code:

    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.canvas.*;
    import javafx.scene.web.*;
    import javafx.scene.layout.*;
    import javafx.scene.image.*;
    import java.io.*;
    import javafx.geometry.*;
    import javafx.scene.Group;
    import javafx.scene.control.* ;
    import javafx.scene.layout.* ;
    import javafx.stage.Stage ;
    import javafx.scene.paint.*;
    import javafx.scene.shape.Circle;
    //main class
    public class BackgroundClassProgram extends Application {
    // application launches at this point
    public void start(Stage st)
    {
    // set the title for the stage
    st.setTitle("Sample creation of background. . .") ;
    //Circle c creation
    Circle c = new Circle();
    //Set the properties of circle
    c.setCenterX(311.0f);
    c.setCenterY(126.0f);
    c.setRadius(112.0f);
    ///  create a hbox
    HBoxhb = new HBox(c);
    // spacing set
    hb.setSpacing(11);
    //  alignment setting for the hbox
    hb.setAlignment(Pos.CENTER);
    //  creation of scene
    Scenesc = new Scene(hb, 290, 280) ;
    // creation of background fill
    BackgroundFill bf = new BackgroundFill(Color.RED ,
    CornerRadii.EMPTY , Insets.EMPTY) ;
    //   creation of background bg
    Background bg = new Background(bf);
    // setting the background
    hb.setBackground(bg);
    // set the scene
    st.setScene(sc);
    //display the result
    st.show();
    }
    // Main Method
    public static void main(String args[])
    {
    //  application launches here
    launch(args);
    }
    }
    

    Example #2

    JavaFX program that displays a timer with the help of API packages.

    Code:

    import java.util.Timer ;
    import java.util.TimerTask ;
    public class TimerProgramSample {
    public static void main(String[] args)
    {
    // timer notification
    System.out.println("Timer starts now...") ;
    // object creation  for timer
    Timertmr = new Timer() ;
    //timer schedule
    tmr.schedule(new TimerTask()
    {
    //run method override
    @Override
    //run method
    public void run()
    {
    //notifying about timer
    System.out.println("Timer starts. . . .") ;
    }
    }, 3000) ;
    //repeats each 20second
    Timer tt = new Timer() ;
    //repeating timer schedule
    tt.scheduleAtFixedRate(new TimerTask()
    {
    //run method override
    @Override
    public void run()
    {
    System.out.println("Timer is working fine. . . .") ;
    }
    }, 0, 3000) ;
    }
    }
    

    Apply now for Advanced Java Training Course

    Copyright 1999- Ducat Creative, All rights reserved.

    Anda bisa mendapatkan server slot online resmi dan terpercaya tentu saja di sini. Sebagai salah satu provider yang menyediakan banyak pilihan permainan.