Friday Apr 17, 2009

Bullet Graph - RIA + JavaFX !

Finally we are able to finish one more article on Data Representation. My special thanks to Stephen Few who has written the concept of Bullet Graph. An awesome way to represent lot of data in one screen. Basically used on Executive Dashboard to compare between predicted value and actual done.

In terms of Animation, this is different in comparison with other Data Rep. Articles. Here the data loading is sequential in nature. Actually if someone is making it for presentation purpose, the best way is to show the animation on Key hit, very similar to what we do in ODP or PPT presentations.Some small code of AppletExtension is also there, which will show you the power of JavaFX API. When you drag this applet out of Browser, you will not see the custom close button.

Feel free to comment or add anything you want in this.

Friday Jul 11, 2008

Applet and JavaFX and Confusion

Two weeks back in BOJUG meeting, I have seen lot many engineers getting confuse with JavaFX. They want to know how to run FX code in browser. Shall we use applet to run FX code. And many more. Though it tough to explain everything in a small presentation but Harish Singh and we have tried our best to explain some of the queries. Yes, FX can be very well run in an applet. I have written one HelloWorld type of example for running FX code inside applet. Its very well same. \*.fx file create a .class file and then handling in the same way as we do with .class file.

Here is a small code for "My Hello World" (HelloApplet.fx)

import javafx.ui.\*;

  content: Label {
    text: "My Hello world!"

Now you have to compile this with javafxc, so that we can use class file. For that you need to download javafx compiler, runtime and some more jars. From this link you can download it.

Now here is little tough part, making html file for applet :-). Tough because you get to know which jar files your code is using. And you will not get documents readily to say you which API belong to which package + API's in themselves are changing. So, you may not able to run your older codes. Anyway, I have written this html code(Hello.html):
    <applet code="javafx.ui.Applet" width=480 height=560
     archive="javafxrt.jar, Scenario.jar, javafxgui.jar, javafxc.jar, javafx-swing.jar, javafx.jar">
     <param name="AppletClass" value="HelloApplet"> 

Don't ask me why I have added some many archive. I got frustrated in knowing what residing where. And so, I have ended up adding all the jar that I have seen in the archive(in the link) :). Check it out, let me know if there exist any problem.

Surprisingly you can call Frame also from applet, check this code:

import javafx.ui.\*;
Frame {
   title: "Hello World F3"
   width: 200
   content: Label {
      text: "Hello World"
   visible: true
In the next blog I will also cover some other way to use on web.

Tuesday Jun 03, 2008

Draggable Applets - 6u10

JDK 6u10 is one of the major attractions in JavaOne 2008. 6u10 came with tons of features like:

1. Kernel JRE download

2. Draggable Applet

3. Improving JS support

4. Better Vista Support 

... and many more

I am here writing the MOST simple example for draggable applet. Off course, Hello World :-).  Here is the code:

import java.awt.\*;
import java.applet.Applet;

public class HelloWorld extends Applet {
    public void paint(Graphics g) {
        g.drawString("Hello World",50,50);
    } // end of paint
} // end of applet

One line code change in the HTML file:

<APPLET CODE="HelloWorld.class" WIDTH=200 HEIGHT=100>
<PARAM NAME="draggable" value="true"/>

And now you can see how applet will come out of the browser and runs as a different process. Closing browser will not going to make any effect on applet life cycle.

You can clearly see the MS Windows in background :) and a very cute close button with the applet, independent applet. And off course a different process in task bar.   


Vaibhav Hi, I am Vaibhav Choudhary working in Oracle with JDK team. This blog is all about simple concept of Java, JVM and JavaFX.


« July 2015