SAN Adventures

pageicon Monday Jun 29, 2009

Kiva FX- JavaFX Application using Kiva API

I was one of the earliest people to have explored the Kiva API. But then i couldn't do anything useful out of it. Few days back it just flashed to me why not create a JavaFX Application which makes use of the Kiva API and also provides fair bit of usefulness. I sat down and went through the API again to check what all it provides. Then i came to a conclusion that let me create some application which the lenders can make use of, say to track the entrepreneurs they have funded. I kept the features limited so as to avoid too much of HttpRequests and Parsing of XML. I spent 3 days of non-stop coding to complete the application. Most of my time was spent on aliging the UI and different components. Hopefully JavaFX gets a JavaFX Builder soon (With the UI support). But to be frank the various features of JavaFX made the application development easier. This would have been more heavy and time consuming if developed using Java Swing. I really liked the "bind" feature of JavaFX. We can bind the data sources to different UI components and let JavaFX do the job of updating the view. I had problems in using the Effects and also few javaFX controls. So i stuck to more basic fade transition and the gradients.

More details can be found here.

Launch the application here.

Do drop in your comments and let me know how i can improve the application.

pageicon Monday Jun 22, 2009

Simple JavaFX Delicious RSS Feed Reader

I had long wished to create a RSS Feed parser which would parse the Delicious bookmarks feed. This time I sat down to code one! But ended up with a simple application. Nevertheless it was a great learning experience for me. The source code can be downloaded from here.

[Read More]
pageicon Saturday Jun 20, 2009

Opening URL in a browser from JavaFX Desktop Application

I searched a bit for opening URL in a browser window using Java and came across the following API:

java.awt.Desktop.getDesktop(new  URI ("www.google.com"  ));

But then when i tried to run the application using this code snippet i got error both in Eclipse 3.4 and in NetBeans 6.5. Eclipse atleast showed the class Desktop in its Intellisense but NetBeans did not do even that. But when i tried to run the same application from the command line it executed with out any exceptions. No idea wat may be the problem. Anyways i figured some way to open a browser using the Hyperlink control of JavaFX. For this i made use of a custom class UrlOpener-

//UrlOpener.java

class UrlOpener{
 public void openURL(String url) throws Exception{
 java.awt.Desktop.getDesktop().browse(new URI(url));
}
}

Now we make use of this helper java class in our JavaFX script hyperlink.fx. This script contains a TextBox control to enter the URL to open. The user can either open the url by clicking on the Hyperlink or by pressing enter from the TextBox control.

//hyperlink.fx

import javafx.scene.Scene;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.scene.control.*;

var urlBox: TextBox;
var hyperLink: Hyperlink;
Stage {
    title: "HyperLink"
    width: 300
    height: 200
    scene: Scene {
        content: [
            Text{
                content: "Opening a URL Demo"
                translateX: 10
                translateY: 40
                font:Font{
                    size: 15
                }
            },
            Label{
                text: "Enter the URL"
                translateX: 10
                translateY: 70
                width: 100
            },
            urlBox=TextBox{
                translateX: 120
                translateY: 70
                width: 100
                action: function():Void{
                    UrlOpener{}.openURL(urlBox.text);
                }
                
            },
            hyperLink=Hyperlink{
                
                translateY: 100
                width: 200
                text: bind "Visit {urlBox.text}"
                action: function():Void{
                    UrlOpener{}.openURL(urlBox.text);
                }

            }

        ]
    }
} 

The screenshot:

I did not try the Applet version. Also this is not working when tried using NetBeans or Eclipse. Have to figure out why so. If there's an alternate way to open the URL via Hyperlink do let me know. I would be really greatful for that. This particular sample uses TextBox and Hyperlink control

pageicon Friday Jun 19, 2009

Key New Features in JavaFX 1.2 SDK

There are a lot of new features added in the JavaFX 1.2 SDK which also includes few changes in the existing packages, changes in the API, changes in the variable names and so on. There are a few changes which have added few major things in the SDK. I would like to throw light on those features.

[Read More]
pageicon Wednesday Jun 10, 2009

My Blog post on DZone links!

I some how figured it out that my blog post on JavaFX Bar Chart here got featured on the DZone links here! Thanks to who so ever has put it up there. This has encouraged me to write more!!!
pageicon Monday Jun 08, 2009

JavaFX Barchart demo

Just finished going thru the BarChart api. Managed to write a simple sample application which shows using BarChart3D. It doesn't take any real time data. Actually the samples written by Vaibhav here helped me a lot. Will actually go thru the RSS Feed API and try out fetching some real time data. Here's the screenshot of the application:

Run the JNLP file here.

Download the source code here

pageicon Saturday Jun 06, 2009

My First JavaFX Application!!!

Was going thru the JavaFX 1.2 API and found a lot of new features some of them are: New JavaFX Controls, New Layouts, Charting API, Local Data Storage among others. I was impressed by few samples which i saw here and here. So i thought of exploring the New JavaFX Controls and created a sample application. 

Screenshot of the application:

Run the JNLP file here.

Run in Applet mode here.

Download the source code here.

Will try out the Chart API as well!!!!