Wednesday Aug 05, 2009

JavaFX and the music world

My friends are well aware that I am not a music aficionado. I use music to relax and as background for the times when I am deep thought (a dangerous past time :-)). In the past (think college) I've been interested in how music is digitized and the physics of waves.

In last few month I was exposed to a new music medium - the music console build by a Indaba. Beyond music, the interesting part for me has been the fact that the new version of the console is built using JavaFX.

Using the console blew me away. I had no idea that there are that many talented people willing to experiment with music and technology. Just a huge opportunity for creativity, a place for artists and geeks.

Friday Jul 24, 2009

Eclipse plugin for JavaFX is on the move

We are in the process of moving the Eclipse plugin for JavaFX, from kenai.com to a more proper place - Eclipse foundation. Developers used to find the plugin at the kenai url, however the download is now available for install in a cleaner way. The process is still a little clunky, however once the plugin becomes an Eclipse project, one would be able to get the plugin through the usual channel, the update center.

Before you can get started with the plugin you'll have to point it to the location of the JavaFX SDK on your computer. Use the preferences (Window | Preferences |  Java | Build Path ...) dialog to set the JAVAFX_HOME varialble. See the screen shot below for more details. In my case the JavaFX SDK has been bundled with NetBeans. No big deal, Eclipse will be able to use this instance.


Tuesday Jun 30, 2009

Build JavaFX viral application with zembly

Building Facebook applications is not trivial. Most of the content is build in PHP/JavaScript and the challenge is to find hosting for your app. Scalability is another issue once the application becomes viral. There is also the issue of ease of deployment of an app once you build it in one of the traditional development environments.

zembly provides an answer to many of the issues described above. Chris put togher a quick guide on how to deploy JavaFX web applications as zembly widgets. The next step would be to show how to produce a Facebook application (I'll leave that as an exercise to the reader ... until my next blog). Below I am reproducing Chris' blog with minor changes.

Web widgetizing a JavaFX application

\* Using a JavaFX applet in a zembly widget. This approach allows zembly to provide the seamless hosting of the widget and development of a server side mashup (a data service in zembly), while JavaFX provides the rich graphics (JavaScript would be used to communicating with the JavaFX runtime). Embedded a JavaFX applet can be done for both HTML widgets as well as widgets used within application types such as Facebook. There are several steps to use JavaFx in a zembly widget (The wiki contains more information about using JavaFX from zembly) :

         1. Upload the jar file containing the JavaFX code as a widget resource.

         2. In the HTML editor, add a script tag to reference the JavaFX JavaScript runtime.

            <script src="http://dl.javafx.com/1.2/dtfx.js"></script>

         3. In the HTML editor, add another script tag to setup the JavaFX applet. The ${res(’Calculator.jar’)} substitution variable is obtained using the add to editor link from the widget resources panel. This variable ensure the URL link is resolved appropriately throughout the widget lifecycle.

            <script type="text/javascript">

              javafx(

                    {

                        archive: "${res('Calculator.jar')}",

                        width: 221,

                        height: 249,

                        code: "calculator.Main",

                        id: "appl"

                    }

                ;);

            </script>

Consuming zembly services in a Java of JavaFX application

\* Consuming data services (see the growing list of public Web APIs) available from zembly in a JavaFX application (running outside zembly). The zembly platform provides an open source client library which allows secure invocation of data services outside zembly. The client library has language bindings for Java and JavaFX. The wiki contains details on invoking data services outside zembly.


Sunday May 17, 2009

Ultimate cloud or crazy idea

Listening to Leo Laporte on the way to work today, I learned about Wolfram Alpha - computational knowledge engine. The concept is fascinating and I've been playing entering all kinds of nouns, expressions, verbs, etc. The results are amazing. It would be very interesting to see if the technologies that are being used to render the results evolve to include, JavaFX, Flash or the like.


 I'd also love to learn about the architecture of the (computational) service. I know that they are using MySQL as their database, however I have no data on their data center. It will be interesting to see if this research influences the future direction of Google.

Monday May 04, 2009

JavaFX IRC channel

If you are an IRC user and looking to get "idle", get tips, news, etc about JavaFX, please join the following unofficial channel: irc://irc.freenode.net/##javafx

If you are not using chatzill, please join the ## javafx channel on freenode. See you there. 

Tuesday Apr 28, 2009

Drag to install on Macs

Apple just released a developer preview of Java based on Java 6 u13. Drag to install is only possible in conjunction with Safari 4 beta and appropriate setting in the Java Preferences console. You'll need ADC membership for the VM bit. Safari is publicly available. 

[Read More]

Friday Mar 20, 2009

JavaFX developer challenge

The JavaFX team is ready to deploy the JavaFX developer challenge. Students and developers should already familiar with the concept. Companies such as Google, Adobe and Microsoft have implemented similar contests to get developers to adopt new technologies.

Here are some tips on how to improve your odds of winning:

  • Use NetBeans 6.5 - it will make you more productive
  • Deploy your application on the web, rather than just submitting the sources - JavaFX is all about build rich user interfaces, and the web is the best way to showcase your work
  • Embed you application in a widget that can become viral within social networks. For instance you could use zembly to build and deploy a Facebook application
  • Don't mix and match in your user interface. JavaFX Script provides a different programming model than Java and while you could call Java (e.g. Swing) from the UI, it will likely not look good. The team is building a new set JavaFX UI controls, however this library is not available yet.

 

Thursday Mar 12, 2009

JavaFX and Ajax

Ken Russell, the architect and author of the new Java Browser plugin has recently completed the work on the JavaFX to JavaScript bridge. In a nusshell, JavaFX web applications could call JavaScript functions & objects in the webpage that embeds the JavaFX app and vice versa. Nota bene: this bridge calls for the plugin to use Java SE 6 update 10 or later.

JavaScript to JavaFX Script

JavaFX Script can be accessed using the synthetic script field which is exposed from JavaFX Script applets to the JavaScript engine.

function someJavaScriptCall() {

var myApp = document.getElementById("myApplet";);

myApp.script.someJavaFXScriptCall();

}

The snippet above, assumes that the Java web application (Applet) embedded in the web page is instantiated with myApplet as id.

JavaScript to JavaFX Script

JavaFX Script can interact with JavaScript on the web page, in a similar way to how Java code can interact with JavaScript. This lets you call JavaScript functions defined on the web page, modify the Document Object Model (DOM) of the web page on the fly, and generally write JavaFX Script apps that integrate well within the web page.

AppletStageExtension.eval("yourJavaScriptCall()";);

Wednesday Feb 11, 2009

JavaFX Mobile ships

The Eran Davidov show is now coming to a mobile device near you. In other words, the JavaFX team at Sun has delivered JavaFX Mobile. The JavaFX platform enables the development and deployment of rich and expressive content and services to end-users across desktop, mobile, browser and TV (due later on this year). This release follows the December '08 shipment of JavaFX 1.0 for desktop.

[Read More]

JavaFX layout considerations

As the team is getting ready to release JavaFX 1.0 Mobile, I was experimenting with layout considerations of deploying of JavaFX applications to mobile devices.

Below are a couple of considerations for developers who will build applications for devices that have typical screen size of 320x240 pixels. The example below (inspired by Josh), draws a centered circle and uses for its radius a % of the width of the device screen size.

The other interesting point that the example illustrates is how to convert a String type into an Number. Java developers will recall using something parseInt to achieve this task (i.e. int foo = Integer.parseInt("7";);). Similarly, in JavaFX you could use this technique as follows:

var myNumber:Number = Integer.parseInt("7");

Serious developers may want to read this blog by Amy Fowler that provides a lot more details on layout management in JavaFX Script.

In general, one has to cautious about calling Java libraries and should stick to the "common" JavaFX APIs. Keep in mind that javafx.ext.swing, javafx.scene.effects packages are out of bounds for mobile developers. Also the mobile emulator (bundled with NetBeans and the SDK) is not yet available for the Mac.

Saturday Jan 31, 2009

Installing JavaFX plugin in NetBeans "All" distribution

 

Most of the developers that want to learn about Sun's new RIA platform - JavaFX, install the bundle that includes SDK, the NetBeans development environment (which includes a JavaFX Script plugin). On the other hand if you are already a developer that uses NetBeans and have adopted the recently release version 6.5 you have a simple way to add install the JavaFX plugin.

Just use the top level menu of the IDE: Tools | Plugin, tab to "Available Plugins" and look for the JavaFX category, select all entries, install and restart NetBeans.

Nota Bene: One of the advantages of using NetBeans to get started with JavaFX is the availability of samples. Open and File | New Project | Samples | JavaFX and you'll note about 40 samples which range from a series of simple building blocks that show you how to work with shapes, transformation, etc. to more advanced examples that illustrate how to invoke web services, or build a media player.

Wednesday Jan 28, 2009

Using println to debug JavaFX

Most of the developers that started programming in the 20th century, before IDEs were broadly used, are familiar with debugging using println statements. While I highly recommend that one uses NetBeans or Eclipse to develop JavaFX RIA applications, I believe certain people will still want to employ old techniques to debug their code.

Here is an example on how to use println in a JavaFX application to print environment variables.

There are a couple of tricks that you may have to be aware of. 

  • You can't use println while you initialize your code (between lines 18 & 34)
  • println will send the output to the console
  • If you want to print onto your UI artifact, you could employ the javafx.scene.text.Text  object
  • Printing environment variables may yield different results depending on your configuration. For instance, using the default - desktop app configuration will give you a different result than when you deploy the app to a mobile emulator

JavaFX application deployed as a clearspring widget


Here is an example of a JavaFX web application, deployed as a clearspring widget.[Read More]

Monday Jan 19, 2009

Learn to program using JavaFX Script

The 1st session of the "15-week JavaFX Programming (with Passion!)" free online course will start on January 30th, 2009. The details of the curriculum can be found at the javapassion.com website.

For registration, all you have to do is to send a blank email to the following email address: javafxprogramming-subscribe@googlegroups.com

Sunday Jan 18, 2009

Database access from JavaFX Script

Given that there is a wealth of JDBC code out there, I suspect that many developers may try to leverage their investment as they build new rich internet applications with JavaFX. I'll be using NetBeans 6.5 to demonstrate a simple example.

We'll use a simple JavaFX script project, which generates hello world code. Use the libraries node in the project view to add the "Java DB Driver".

As you can see, I am calling TalkToJavaDB.getRecord() which returns a java.lang.String, which in turn I assign to the Text object in my JavaFX script. I am using the Java String object to store an index of the java.sql.ResultSet I get from connecting to a JavaDB (derby) that ships with either Java 6 or GlassFish (v2 in my case).

This example is very trivial and may improve it in time to iterate over the ResultSet and present the data in a more visually apealing way (after all JavaFX enables developers to build great user interfaces, in many cases in half the time and with a lot less code)

Friday Jan 16, 2009

Webstarting your JavaFX application

Here is another tip on how to deploy your JavaFX application using the Java Web Start technology. Of course if you are using a tool such as NetBeans, the whole process is very simple. You would just change you project properties to use "Web Start Execution" and you are done (the IDE will generate the appropriate JNLP file and a browser specific JNLP which includes the applet-desc tag).

If you have to handcode the JNLP file for your application, edit the xml code below, as needed and save with a file with a .jnlp extension. Once you've done this you are ready to deploy the resource and your customer will be able to invoke the JavaFX application by the URL (http://<someplace on the web>/<application_name>.jnlp)

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="file:/<URL_to_jnlp_file>/" href="<application_name>.jnlp">
    <information>
        <title>App Name</title>
        <vendor>blah</vendor>
        <homepage href=""/>
        <description>blah blah</description>
        <offline-allowed/>
        <shortcut>
            <desktop/>
        </shortcut>
    </information>
    <resources>
        <j2se version="1.5+"/>
        <extension name="JavaFX Runtime" href="http://dl.javafx.com/javafx-rt.jnlp"/>
        <jar href="<Application_name>.jar" main="true"/>
    </resources>
    <application-desc main-class="<package_name_for_your_app>.Main"/>
</jnlp>

Thursday Jan 15, 2009

Deploying a JavaFX web application

Deploying a JavaFX web application (applet) is trivial. Just use the following code in your HTML page:

<script src="http://dl.javafx.com/dtfx.js"></script> <script>     javafx(         {               archive: "Foo.jar",               draggable: true,               width: 200,               height: 200,               code: "foo.Main",               name: "Foo"         }     ); </script>

The snippet assumes that you build and application called "Foo" (package name "foo";). One may only want to use the "draggable" attribute if the application is intended to run on Java 6 update 10 (or later) which gives the opportunity for users to install a web application on the desktop.

Wednesday Dec 10, 2008

Eclipse plugin for JavaFX Script

In addition to the support for JavaFX Script in the NetBeans IDE, there is also an Eclipse plugin. Developers can now kick the tires of this new extension of the Java platform in their favorite IDE. At a glance the Eclipse plugin is not as sophisticated as the NetBeans one, however the deployment support is invaluable. One can build and application and just before deploying it, can choose to do this in the browser, desktop or the mobile emulator. 

Users should download the official documentation. More advanced users could use the instructions below:

Table of content

  1. Installation
    1. Install JavaFX SDK
    2. Install Eclipse
    3. Install Plugin
  2. Hello World
    1. Creating JavaFX Project and configuring JavaFX SDK
    2. Adding files
    3. Running
    4. Building
    5. Configuration options
    6. JavaFX Help

Installation

Download and install the JavaFX SDK for Windows or Mac Os X

Install Eclipse

Plugin require Eclipse 3.4 or newer. We recommend downloading Eclipse IDE for Java EE Developers for Windows or Mac OS X. Then follow the installation instructions.

Install plugin

  1. Download plugin:
  2. Unzip into eclipse installation directory
  3. There should be new files in ECLIPSE_ROOT/plugins and ECLIPSE_ROOT/features
  4. Run Eclipse

Hello World

Creating JavaFX Project and configuring JavaFX SDK

  1. Start eclipse. You will see the basic layout of workbench.
  2. In Package Explorer view click right mouse and select New > Java Project
  3. Create new JavaTM project.
  4. Name it MyJavaFXProject and press Finish button. The new project appears in Package Explorer.
  5. Open project popup menu and select JavaFX > Add JavaFX Nature.
  6. The JavaFX perspective is activated. If this is first time you are adding JavaFX nature into Java Project you will be asked for setting up JAVAFX_HOME property.

    To set up JAVAFX_HOME property follow steps bellow:
    1. Press OK on message dialog. No thanks, I preffer Cancel button.
    2. You should see dialog below with JAVAFX_HOME set to (empty) value.
    3. Press Edit... button on right side to bring up edit window.
    4. Select Folder... button and select installation folder of JavaFX SDK.
    5. Press OK on Folder Selection dialog, press OK on Edit Variable Entry dialog.
    6. Press OK on Preferences dialog. The JAVAFX_HOME variable has been set up.
    If you select Cancel button on error dialog you will skip this setup and system will never ask you for this again. To setup this later just follow this instructions.
  7. Voila! you have first JavaFX Project.

Adding files

  1. Expand MyJavaFXProject. Left click on src folder. Then select New > Package and type into Name package name com.sun.eclipse.example.
  2. Left click on src/com.sun.eclipse.example folder. Then select New > Empty Script.
  3. The New File wizzard will appear. Type Main into Name field.
  4. Press Finish button and empty new JavaFX script is created.
  5. Let's focuse on Snippets view. There is a lot of code snippets to help you develop your application. Expand Applications and select Stage.
  6. Drag Stage into editor window and drop. The Insert Template: Stage dialog appers. Change title into Hello World!.
  7. Press Insert button to insert template result into source code. Done

Running

Running application in Eclipse is very easy.

  1. Press Run button on toolbar to lunch application.
  2. If you are running first time the Edit Configuration dialog appears.
    All options are setup to default values. The most interesting part is Profile - Target option. Here you can set up execution environment. Possible options are:
    • Desktop profile - Run as Application
    • Desktop profile - Run as Applet
    • Desktop profile - Run with WebStart
    • Mobile Profile[?] - Run in Emulator
  3. Press Run to start application. The console window will appear notifying you about progress of execution.

Building

Building is in Eclipse platform provided automatically. For more building options open Project menu

Configuration options

  1. Select project in Package Explorer, right click and select Properties.
  2. The Properties dialog appears. Select JavaFX Defaults.
    Here you can edit several default parameters used during execution and deployment process of JavaFX Project. For more information about meaning of available options see JavaFX Packager Documentation.

JavaFX Help

Plugin provide easy acces into JavaFX SDK documentation. You can invoke help by Help > Java FX > JavaFX Script Documentation or press Ctrl + F1

Footnotes:

  • Any time you can setup or change the JAVAFX_HOME variable following these steps:
    1. Open Window > Preferences
    2. Expand Java > Build Path and select Classpath Variables
    3. Edit JAVAFX_HOME
  • You can switch profiles in SDK by following steps:
    1. Right click on project name. SelectProperties > Java Build Path > Libraries
    2. Double click on JavaFX System Library. The Edit Library dialog appears. Here you can set up profile to use.

Saturday Nov 29, 2008

JavaFX Script Language Reference

Robert Field just finished the draft of the JavaFX Script Language reference.[Read More]
About

octav

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today