Thursday, May 29, 2008

GUI Internationalization in NetBeans

Internationalization is one of the popular project which is moving at faster pace now-a-dayz. Netbeans has its own internationalization module. Internationalization permits applications to be adapted to various languages and regions without requiring engineering changes or recompilation. Internationalized programs enable textual elements, such as status messages and GUI component labels, to be stored outside the source code and retrieved dynamically rather than hard-coded in the program.

Here is a use case of simple GUI being Internationalized.

Open a new project with JFrame form added. (you can do this by right clicking on the project node then New and selecting JFrame Form).
I created a simple GUI to demonstrate the steps.

Now right click on project node and go to New->Other->Other->Properties.
Name it Bundle. Add the following contents to that file.



Now you need to set the name of the respective component by right clicking and editing. Note that the name must be similar to what you have written in Bundles file.
Open the UI class in the design mode. Right click on Form node->Properties.
You should see a window like this.


Check Automatic Internationalization. Click on ellipsis(..) to select the desired locale. I have chosen French(fr_FR). Right click on Bundle.properties and open it. You should see something similar to this,


Save it.Go to Design mode window(Editor Window). Now in the navigator window right click on the Form option and Reload.
Right click on the project name node, Goto properties->Run then enter this
"-Duser.language=fr -Duser.country=FR" (Without Quotes)
in the Virtual Machine Argument TextField and run the project.You must see your GUI Internationalized.



Howz That now......

Thursday, May 22, 2008

Another war of Titans


Good news for all students worlwide,
Sun has officially launched Student reviews contest for students as well as Sun Campus Ambassadors. Loadsa prize to be won. Here are some details,
The contest will have two groups: one for students who are not Sun Campus Ambassadors, and another comprising Sun Campus Ambassadors. For each group, there will be a grand prize of $250 in Visa Debit Card, and 5 second prizes of $100 each in Visa Debit Card.
Hurry up guys as the last date for the entry is June 6, 2008.

All the best! Get going!....

Sunday, May 18, 2008

Checking out projects from Java.net through Netbeans

Hi folks,
Recently I got interest(not sure from where) in CVS and SubVersioning. The features(integration etc) provided by NetBeans is excellent to do check outs. Be it CVS or SVN.
Out of curiosity I decided to check out a special project hosted on java.net. It is Aerith.
It has many dependencies. It requires JDK 6.0 and later versions to run. You need to download JOGL . Be sure to download jogl.jar as well as the jogl native libraries for your platform.
Install JOGL by unjarring the jogl-natives[your platform].jar file. It should create several native libraries. Put the native libs in your library path(/usr/lib/ in my case) and the jogl.jar in your classpath. It also requires dependency jar files like JLayer 1.0 and TimingFramework .
Now you need to check out the source code for swingx . For this to happen you need to create an account on java.net.
Open NetBeans, go to Versioning->CVS->Checkout as shown,



then enter the name of the module.


Click finish. You will see the source code being downloaded to the above mentioned directory.


Now you need to download the code for Aerith project from SVN. To check whether svn is installed or not on linux type svn in console. You need to download the rpm package or the source code to install it otherwise. You will get further information about SVN on linux here. Download and instaalation instructions are here. I just did apt-get install svn (I use kububtu Hardy Heron).
Check out the version of svn by issuing svn --version command. NetBeans needs another svn client to be installed on your system. NetBeans 6.1 supports versions > 1.3. The clients which I know are kdesvn and rapidsvn.

After you install a svn client you need to provide the installation path of these clients to NetBeans. By default it is /usr/lib/ on linux. Go to Versioning->Subversion->Checkout. It'll ask you to enter the path. If it is proper you should see a window similar to this.

Input the proper repository URL and click Next,

If you are not sure about the repository folder click browse button. Browse the repository for folder containing the proper source code and click finish.

Now that the checking out is over , you need to resolve certain dependencies. Open the project you checked out. Right click on the project and go to Resolve Reference Problems. Click on resolve to locate the required jar libraries on your system. Now you need to tell Netbeans where your Jogl.jar is. Right click on Libraries under your project tree. Then click on Add JAR/Folders and locate the relevant jar file. Now build the project.
Note: I got the following errors:
init:
deps-jar:
Created dir: /home/rajath/NetBeansProjects/trunk/build/classes
Compiling 99 source files to /home/rajath/NetBeansProjects/trunk/build/classes
/home/rajath/NetBeansProjects/trunk/src/com/sun/javaone/aerith/g2d/AnimationUtil.java:20: package com.sun.xml.internal.messaging.saaj.soap does not exist
import com.sun.xml.internal.messaging.saaj.soap.Envelope;
/home/rajath/NetBeansProjects/trunk/src/com/sun/javaone/aerith/ui/ActionButton.java:35: package com.sun.xml.internal.messaging.saaj.soap does not exist
import com.sun.xml.internal.messaging.saaj.soap.Envelope;
/home/rajath/NetBeansProjects/trunk/src/com/sun/javaone/aerith/ui/WaitOverlay.java:31: package com.sun.xml.internal.messaging.saaj.soap does not exist
import com.sun.xml.internal.messaging.saaj.soap.Envelope;
/home/rajath/NetBeansProjects/trunk/src/com/sun/javaone/aerith/ui/fullscreen/IndyFullScreenRenderer.java:49: package com.sun.xml.internal.messaging.saaj.soap does not exist
import com.sun.xml.internal.messaging.saaj.soap.Envelope;
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors
BUILD FAILED (total time: 6 seconds)


Click on the errors to navigate to the respective location of the source code and try to resolve unused imports. Save it and rerun the project.
Ah.. Now you must be able to see the gorgeous Aerith window. Enter your Flickr username and enjoy. If your username is invalid you may end up in getting Exceptions.
Few ScreenShots of Aerith:

You can browse photos. You can prepare a trip report and do lots more.

It is a Filthy Rich Client Application.