Install JavaFX Application …From Apple's Mac App Store

Probably the first JavaFX / Java application called "Ensemble" is available directly from the Mac App Store.

[The application was taken from the store to fix some glitches, but it should come back soon]

Tip: if you are a developer, there are easier ways to get the Ensemple running on your Mac :-)


Cloudy Jakarta EE and MicroProfile: Microservices, Clouds and Beyond Jakarta EE / MicroProfile airhacks workshops at MUC airport, Winter Edition

airhacks.fm the podcast:

Stay in touch: airhacks.news.

Transparent Windows (Stage) With Java FX 2

To make the main Java FX window completely transparent, you only have to set the StageStyle.TRANSPARENT and the Scene#setFill(null):


import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

public class TransparentStage extends Application {

    @Override
    public void start(Stage stage) {
        stage.initStyle(StageStyle.TRANSPARENT);
        Text text = new Text("Transparent!");
        text.setFont(new Font(40));
        VBox box = new VBox();
        box.getChildren().add(text);
        final Scene scene = new Scene(box,300, 250);
        scene.setFill(null);
        stage.setScene(scene);
        stage.show();
    }

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

Checkout the TransparentStage sample (source code).


Cloudy Jakarta EE and MicroProfile: Microservices, Clouds and Beyond Jakarta EE / MicroProfile airhacks workshops at MUC airport, Winter Edition

airhacks.fm the podcast:

Stay in touch: airhacks.news.

Building Java FX 2 Libraries From Source With Maven 3

  1. Get the sources: hg clone http://hg.openjdk.java.net/openjfx/2.2/master/rt. For subsequent updates use: hg pull -u
  2. Create a JavaFX profile with a pointer to the javafx 2.2. SDK. Hence not all sources are open yet, this is a necessary step:
    
    <profile>
    	<id>javafx</id>
    <activation>
    	<activeByDefault>false</activeByDefault>
    </activation>
    <properties>
    	<fx.home>[PATH TO JAVAFX INSTALLATION]/javafx-sdk2.2.0-beta/</fx.home>
    </properties>
    </profile>
    
       
  3. Execute: mvn -Pjavafx clean install
  4. You should see the following output:

    
    [INFO] javafx ............................................ SUCCESS [0.740s]
    [INFO] test-stub-toolkit ................................. SUCCESS [2.676s]
    [INFO] javafx-beans-dt ................................... SUCCESS [1.080s]
    [INFO] javafx-concurrent ................................. SUCCESS [1.385s]
    [INFO] javafx-ui-controls ................................ SUCCESS [9.607s]
    [INFO] javafx-designtime ................................. SUCCESS [0.479s]
    [INFO] javafx-ui-common .................................. SUCCESS [8.973s]
    [INFO] javafx-rt ......................................... SUCCESS [2.241s]
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 27.337s
    
    

  5. Pick your own fx-runtime library from: javafx-ueber-jar/target/jfxrt.jar
  6. Run tests, file bugs: Java FX Jira :-)


Cloudy Jakarta EE and MicroProfile: Microservices, Clouds and Beyond Jakarta EE / MicroProfile airhacks workshops at MUC airport, Winter Edition

airhacks.fm the podcast:

Stay in touch: airhacks.news.

Setting JavaFX 2 Runtime At Start (And Solving "Unable to read ../rt/" Problem)

If you run "java -jar killer-app.jar" on a machine where JavaFX SDK was installed with a simple "unzip" (like a Mac), you will get the following error:


Unable to read ../rt/lib/jfxrt.jar
Unable to read ../../../../rt/lib/jfxrt.jar
Unable to read ../../sdk/rt/lib/jfxrt.jar
Unable to read ../../../artifacts/sdk/rt/lib/jfxrt.jar

Because the Java FX launcher does not know where to find the runtime, it falls back to the default location.
To solve this problem, just pass the system property: javafx.runtime.path with the JavaFX SDK location at start:

java -Djavafx.runtime.path=[THE UNZIPPED JAVA FX SDK]/rt -jar killer-app.jar


Cloudy Jakarta EE and MicroProfile: Microservices, Clouds and Beyond Jakarta EE / MicroProfile airhacks workshops at MUC airport, Winter Edition

airhacks.fm the podcast:

Stay in touch: airhacks.news.

JavaFX 2.0 CSS Reference

All JavaFX 2 components can be styled with CSS 3. The CSS JavaFX 2 reference is available here: http://docs.oracle.com/javafx/2.0/api/javafx/scene/doc-files/cssref.html. To activate your custom CSS you only have to add a resource containing the CSS styles to the javafx.scene.Scene:


        Scene scene = ...
        scene.getStylesheets().add(this.getClass().getResource("javafxrocks.css").toExternalForm());
        stage.setScene(scene);
        stage.show();


Cloudy Jakarta EE and MicroProfile: Microservices, Clouds and Beyond Jakarta EE / MicroProfile airhacks workshops at MUC airport, Winter Edition

airhacks.fm the podcast:

Stay in touch: airhacks.news.

How To Compile Java FX 2 Applications With Maven 3

Java FX 2 is Java. To build a Java FX application you only need an additional JAR: jfxrt.jar which contains the Java FX UI classes. The JAR comes with Java FX SDK, but is not included in the public maven repository. You can point to the Java FX SDK installation with Maven's system scope dependency:


<project>
...
    <dependencies>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>javafx</artifactId>
            <version>2.0</version>
            <systemPath>${fx.home}/rt/lib/jfxrt.jar</systemPath>
            <scope>system</scope>
        </dependency>
    </dependencies>
</project>

The resolution of the ${fx.home} variable ensures the pom.xml independency on user-specific settings:

<settings>
...
<profiles>
        <profile>
            <id>javafx</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <fx.home>[PATH]/javafx-sdk2.1.0-beta/</fx.home>
            </properties>
        </profile>
    </profiles>
</settings>


Cloudy Jakarta EE and MicroProfile: Microservices, Clouds and Beyond Jakarta EE / MicroProfile airhacks workshops at MUC airport, Winter Edition

airhacks.fm the podcast:

Stay in touch: airhacks.news.

Swing Looks ...Great!: NetBeans 7 (IDE + RCP) With New Synthetica L&F

Synthetica V2.13 and SyntheticaAddons V1.5 L&Fs for Swing are released. See also NetBeans RCP with Synthetica L&F.
Some screenshots with NetBeans 7 IDE with Synthetica L&F:




Cloudy Jakarta EE and MicroProfile: Microservices, Clouds and Beyond Jakarta EE / MicroProfile airhacks workshops at MUC airport, Winter Edition

airhacks.fm the podcast:

Stay in touch: airhacks.news.

Swing Looks ...Great! - New Theme For Synthetica

The BlackEye look and feel was already introduced. Synthetica comes with a new theme called "Classy":



WebStart Demo works perfectly on MacOS X. Its not a trick - its Swing :-).


Cloudy Jakarta EE and MicroProfile: Microservices, Clouds and Beyond Jakarta EE / MicroProfile airhacks workshops at MUC airport, Winter Edition

airhacks.fm the podcast:

Stay in touch: airhacks.news.

Hello JavaFX 2! - A TableView Component

A table control was missed in JavaFX 1.3. JavaFX 2 comes with a new table component:

import javafx.application.Application;
import javafx.application.Launcher;
import javafx.collections.FXCollections;
import javafx.collections.Sequence;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.table.TableColumn;
import javafx.scene.control.table.TableView;
import javafx.scene.control.table.model.SequenceTableModel;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start() {

        Stage stage = new Stage();
        stage.setTitle("Hello Table");

        final Group root = new Group();
        Scene scene = new Scene(root);
        stage.setScene(scene);

        Sequence children = root.getChildren();
        children.add(getTableView());
        stage.setVisible(true);
    }

 	//TableView is a node...
    public static Node getTableView() {

        Sequence data = fetchDataFromServer();

        TableView tableView = new TableView();
        SequenceTableModel tableModel = new SequenceTableModel(data);
        tableView.setModel(tableModel);

        TableColumn[] columns = buildColumns(data);
        tableView.getColumns().addAll(columns);
        return tableView;
    }

    //sequence is an Observable java.util.List. It could come directly from e.g. JPA EntityManager.
    public static Sequence fetchDataFromServer() {
        return FXCollections.sequence(
                new Person("Duke", "Java"),
                new Person("DukeFX", "JavaFX"));

    }

    public static TableColumn[] buildColumns(final Sequence data) {
        TableColumn firstNameCol = new TableColumn();
        firstNameCol.setText("First");
        firstNameCol.setGetCellData(new TableColumn.GetCellData() {

            @Override
            public Object get(long row, int col) {
                return data.get((int) row).getFirstName();
            }
        });

        TableColumn lastNameCol = new TableColumn();
        lastNameCol.setText("Last");
        lastNameCol.setGetCellData(new TableColumn.GetCellData() {

            @Override
            public Object get(long row, int col) {
                return data.get((int) row).getLastName();
            }
        });

        return new TableColumn[]{firstNameCol, lastNameCol};

    }

    public static void main(String[] args) {
        Launcher.launch(Main.class, args);
    }
}


public class Person {

    private String firstName;
    private String lastName;

    public Person(String firstName, String lastName) {
        this.firstName = firstName;
        this.lastName = lastName;
    }
//with getters.
}

A similar example comes with JavaFX 2 already. I just decomposed the origin example in several methods to see what happens behind the scenes.
Java FX 2 application can be compiled having jfxrt.jar in the classpath and launched like any other Java application: java -cp javafx-sdk2.0-ea/rt/jfxrt.jar com.abien.table.Main
Even in the case of the preview the startup performance is <1 sec and significantly faster, than 1.X version.
This post is based on Java FX 2 Early Access - the API and runtime can change any time.
Sees official JavaFX roadmap for more details.


Cloudy Jakarta EE and MicroProfile: Microservices, Clouds and Beyond Jakarta EE / MicroProfile airhacks workshops at MUC airport, Winter Edition

airhacks.fm the podcast:

Stay in touch: airhacks.news.

Online Workshops
realworldpatterns.com
...the last 150 posts
...the last 10 comments
License