Giter Club home page Giter Club logo

playfx's Introduction

PlayFX

build status

PlayFX is a light framework for managing multiple scenes in JavaFX. More specifically, it provides an easy way to manage the different states of a JavaFX application and to pass from one to another. In addition, it comes with an embedded Dependency Injection system.

Quick start

Launch the application

The code required to launch a JavaFX application with PlayFX is pretty close to the standard JavaFX's API.

The heart of the framework is the Play class, which represents a set of Scenes. Its use is demonstrated in the following code snippet :

public class Launcher extends Application {
	
  @Override
  public void start(Stage primaryStage) throws IOException {	
    // Initialize the play
    Play play = new Play(primaryStage);

    // Prepare a new scene and call it "welcome". 
    // It is semantically equal to FXMLLoader.load
    play.prepare("welcome", WelcomeController.class.getResource("welcome.fxml"));

    // Put the scene "welcome" on the stage. It is semantically equal to stage.setScene
    play.setScene("welcome");

    // Finally, let the show begin ! It is semantically equal to stage.show
    play.show();
  }

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

Change current Scene

Once a scene has been prepared, the setScene method can be used to show it:

// into WelcomeController
play.prepare("users", UsersController.class.getResource("users.fxml"));
play.setScene("users");

This method has optional parameters that can be specified to trigger an animated transition when opening the new scene.

Inject dependencies

Provide values to inject

PlayFX's main advantage is its ability to inject controllers. Values to inject can be specified via three different ways :

  • command line arguments,
  • custom factory method,
  • property file.

Detailed explanations can be found in the relevant wiki's section.

Ask for values

A controller can ask for a value by annotating a field with @Inject :

public class LoginController implements Initializable {
	
    @Inject private String usr;                      // will inject the value "usr"
    @Inject private String pwd;                      // will inject the value "pwd"
    @Inject(name="app.title") private String title;  // will inject the value "app.title"
	
    // rest of the class
}

Documentation

Usage, documentation and samples can be found on PlayFX's wiki.

Installation

As of now, PlayFX is not mature enough to be delivered through Maven. Hence, one has to build library's JAR manually in order to use it in a project.

Generate JAR through Maven

Important: you must run Maven 3.x with a JRE 9 in order to launch the build.

  • Clone the repository:
git clone https://github.com/KazeJiyu/PlayFX.git
  • Launch maven build:
cd PlayFX
mvn clean package
  • The JAR file should have been generated in target as fr.kazejiyu.playfx.jar

Java 9 Support

PlayFX is Java 9-aware. Its Maven build generates multi-release JARs that can be used indifferently from Java 8 and Java 9 applications.

playfx's People

Stargazers

 avatar  avatar

Watchers

 avatar

playfx's Issues

Java 9 support

What do to about Java 9 ?

Commit 33bc47b temporarily disabled Multi-Jar release because Travis was unable to build the JAR.

Is MR really a good solution for PlayFX ? Splitting the sources between Java 8 and Java 9 ones double maintenance workload...

Need some time to investigate the issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.