Christian Java: A Lesson On Temptation

Today, with the help of Java, we take a light hearted look at an important topic pertaining to our religious faith in Christ: Temptation. No need to talk much, the code speaks for itself.

Christian frank = Christians.findByFirstAndLast("Frank", "Adams");
List<Temptation> temptations = Devil.getTempations();

boolean succeeded = false;

for(Tempation t: tempations) {
    succeeded = t.tryOn( frank );

    if( succeeded ) {

if( succeeded == false ) {
    MaturityLevel maturityLevel = frank.getMaturityLevel();

    if( maturityLevel.getDescription().equals("baby") ) {
        Devil.setNextTrialFor(frank, Period.getInstance("D3") ); // next 3 days

    else if( maturityLevel.getDescription().equals("adult") ) {
        Devil.setNextTrailFor(frank, Period.getInstance("I60") ); // next 60 seconds. We need to try harder

That’s all class. Anyone wanna do that code in Javascript? Might provide a bit more syntactic sugar :). Have a blessed day!!!

L & F Concept. Can This Be Done In Java Today?

Windows 8 Desktop UI Concept

I came across an awesome UI Concept for what could have been the desktop UI for Windows 8 yesterday whiles reading around on the Windows 8 blog. I immediately fell in love with the UI and personally WISHED this is what Microsoft should have come up with along side Metro as an upgrade to the Windows Desktop Experience.

After drooling over the UI for God knows how long and reading up on the comments, I asked myself, “How easily can such a UI be created for a Java Desktop (Swing/JavaFX) Application?”

I’ve taken the time to look around the Internet for Look and Feels for Java that come anywhere near this UI Concept and I have not found any as yet. I tried playing around briefly myself and realized the concept can be achieved but requires a bit of hard work (what doesn’t).

All in all I think the UI Concept is just the bomb, and personally I would be glad if Synthetica or Substance L&F had such a theme. It would be serious hit in my opinion.

Let me know in the comments what you think about this UI concept as well as the potential for coming up with something this stunning for a Java Swing/JavaFX application today.

Something I Would Love To Do In Java

Java is a pretty cool language, and I think it is good for teaching the basics about programming. The following is just something I look forward to doing in future versions of Java if Object literals are added.

Here is how u define a rectangle in JavaFX using Java at the moment

Rectangle rect = new Rectangle();

Here is how I would love to be able to define it,

Rectangle rect = new Rectangle({
   fill: Color.RED,
   width: 200,
   height: 100,
   x: 20.0f,
   y: 20.0f

I believe I have been spoiled by my usage of Javascript, and I could use other VM languages, but I think this is just fun to look at. This inherently has issues, because there would need to be to be a lot of Type Casting in order to get the variables out or to set them accordingly, because the Map passed as the argument would need to be defined as HashMap<String, Object> to ensure any value could be passed. The implementation of the Rectangle class would then need to internally map these properties to the right variables somehow.

With Collection Literals in Java 8 onwards, this all will be possible, but the other issue would be if the various UI Classes like Rectangle would be refactored to make the above code possible. I highly doubt it personally, but nothing is impossible.

I will certainly play around with this a bit later. Feel free to share your own ideas in the comments below.

Oracle Did Not Get The Memo About Annoying Users

Oracle recently release Netbeans 7.1 Beta and JavaFX 2.0 and made them available for download from I managed to get the download for Netbeans 7.1 Beta last night without fuss and completed the installation, also without fuss. I expected the JavaFX SDK to be bundled, but it was not.

Trying to download the SDK has become an exercise in futility as I’m presented with Login screens, failed login attempts, password resets and lastly server error pages. Switching browsers from Opera to IE gave me more than an error page and at least enabled me to access my Oracle accounts to reset my password, but the download for the JavaFX 2.0 still gives me an error message at the time of writing.

Whiles struggling with all this, I took time to read the introduction to FXML development for JavaFX 2.0 and compared it to Javascript /XAML development for the Win 8 applications and realized a vast similarities. It would be interesting to see which is the dominant application platform a year from now.

Oracle need to understand that if they want people (developers) to adopt a product they need to make it available without hassle, and then provide compelling services on their website where people can choose to register to be a part of. Even Microsoft are giving away downloads of the Win 8 OS without the need for an account. Oracle need to step up and move away from bureaucratic thinking and get with the programme.

Enough ranting, going back to try the download again.

Java and the Windows 8 Metroverse

After watching and re-watching the Windows 8 keynote, I kicked off a download (still in progress, damn u 512Kbps) to get the 32bit ISO so I can try out the software for myself. During this time of waiting and dreaming of what to build to test the platform, I’ve been considering our beloved Java, particularly JavaSE and where it fits in with the bold re-imagining of Windows. Continue reading “Java and the Windows 8 Metroverse”

Apache Pivot Needs A GUI Designer (IDE)

I’ve been looking and reading around the Apache Pivot project in the past 48 hours and an I must say, without having written a single line of code, I’m totally impressed with the direction of the project. I have a few gripes with certain API calls but that aside the project direction puts it at par with (or quite close to) Adobe Flex and Microsoft Silverlight developments.

Reading around through the documentation, I realised the use of BXML (Bean XML) was quite extensive and could be even more extensive if the application was large and this brought to mind the potential of having a designer tool akin to Adobe’s Flash Builder or Dreamweaver to help generate the BXML Content and make the developer’s work a bit easier. Such as designer might be a tad easier to construct than even a pure Java Swing Designer (e.g. Netbeans’ Matisse) but I’m no expert there, just that in my mind, the logic for the outputted code seems simpler – do correct me if I’m wrong.

With regards to the IDE for this project, I believe there are two options:

  1. Building one from Scratch using Java and use Apache Pivot as the UI library (the developers might fancy this)
  2. Build one on top of the Netbeans or Eclipse platform either from scratch or as extension, similar to what was done for JavaFX Script in late 2009

In any case, a good UI designer will help spur users onto adoption, if the demos alone are not enough (they certainly got me interested).

I plan on potentially picking up Apache Pivot one of these days if a client project gives me the opportunity because currently I dabble in more PHP/JS than anything Java, but I see great potential in the project and I think Oracle might either need to take a leaf from their book perhaps in Java 9, if client side Java development is still vibrant then.

UPDATE: Tom Parker has posted a nice link in the comments below to some work which has already been done to get Pivot running in the context of Netbeans. Do check it out.

JSON In Java. Where Should It Go?

As usual, it’s Saturday night and like the geek I am, I’m here thinking about the weirdest things. Tonight’s question is simple: “If a JSON library was to be integrated into Java SE, where would it go?”

Having worked with PHP a lot in the past year, with respect to the my current open source project KAN CMS, I find the use of AJAX and JSON to very helpful. What more, with PHP’s built in support for JSON parsing and serialization, the whole process is just fun. This got me thinking, what if a JSON library was included in the standard Java SE stack, how useful would it be, and again where would it go?

There is a public JSON library available for download and use over at, which I have used it once in a previous mini project. I found it particularly useful although I did not stress test it much, since my application was small. That notwithstanding, with the high number of Web Services that use JSON as a communication format, having a native JSON implementation in the Java SE stack would be very good to help developers easily build small application that consume these services without relying much on third party libraries, although these libraries maybe small.

About packaging, the library uses the “org.json.*” package format, so assuming Oracle decided to include that library (or another implementation) in the standard Java, I wonder: “where would they stick it?”

  • java.json.*
  • java.text.json.*
  • java.util.json.*
  • javax.json.*
  • or just keep it in org.json.* with the rest of the strange bunch?

Well, I don’t think this worth loosing sleep over, since Oracle are too busy suing Google’s arse to think about adding new libraries to the currently almost bloatware Java SE, but it certainly is something think about.

Cool JavaFX 2.0, But What Happened To JFileChooser?

JFileChooser With Missing Icon (Netbeans)
JFileChooser With Missing Icon (Netbeans)

In the midst of all the good news about JavaFX 2.0 and the reinvested interest in the Java Swing Platform by Oracle at JavaOne, I have to ask myself: what happened to JFileChooser? In all the articles I have read in the past year or so about all the cool and upcoming features in the Java 7 and the new component(s) being introduced the Swing library, I have heard very little about JFileChooser or any improvements planned for the platform.

There have been a lot of complaints in the past about poor performance and a lack of some basic functionality for that component. There were even some mentions of the component being replaced with a Native Implementation sometime back, but there has not been any concrete word on that. Personally, my current pet peaves with the component include:

  • Way too minimal right-click PopupMenu – only New Folder, Rename, View and Refresh are implemented. This minimal popup is also way to difficult to extend by the entry level user. Also, drag and drop file handling is implemented, so why is it so difficult to include Open/Select, Cut, Copy and Paste as basic options in the default popup menu?
  • Poor performance for listing directories and their contents when zip archives are included
  • Lack of decent Directory View (possibly as a tree)
  • Ability to use “\\<pc-name>” option on a Windows based system to navigate to a network location

Other more advanced users have other problems with the component but these are the few I feel are general problems and could be fixed or improved.

The current “Open Project” and “Open File” implementations in the Netbeans IDE seem to have some very useful implementations of the JFileChooser and some have even advocated that those components be ported back into the main JDK source if possible, but that is yet to be seen or determined.

All in all, I think the JFileChooser component needs some attention, because it certainly is starved for some.

It Takes 2: From Java 2 to JavaFX 2.0

From Java 2 to JavaFX 2
From Java 2 to JavaFX 2

After hearing about Oracle’s new Road Map for the JavaFX 2.0 release expected to be made available next year, I found it sort of funny to realize the similarity between what it took for Java to become successful and what it probably is going to take for JavaFX to be become successful.

Up until version 1.6 of the currently successful Java Platform, it carried the brand “Java 2 Platform v1.x” and this was basically the platform I met when I begun my programming career. According to Wikipedia:

J2SE 1.2 (December 8, 1998) — Codename Playground. This and subsequent releases through J2SE 5.0 were rebranded Java 2 and the version name “J2SE” (Java 2 Platform, Standard Edition) replaced JDK to distinguish the base platform from J2EE (Java 2 Platform, Enterprise Edition) and J2ME (Java 2 Platform, Micro Edition). Major additions included reflection, a Collections framework, Java IDL (an IDL implementation for CORBA interoperability), and the integration of the Swing graphical API into the core classes. a Java Plug-in was released, and Sun’s JVM was equipped with a JIT compiler for the first time.

So what is similar in between Java and JavaFX at this point? That will be their version number. It seems Java and JavaFX will potentially owe their success to their “second” major version. From the road map presented by Oracle and the expected changes with respect to API, language and integration changes, I expect if finished in time and coupled with a possible Java 7 release around the same time, JavaFX 2.0 is set to become the next best thing in the RIA and Java UI development arena.

I so far have not used JavaFX for anything more than a demo app and an attempt at making a Flash type web banner animation. But with the proposed changes, I feel I can immediately drop JavaFX 2.0 into my current application to pimp up the UI and deliver a whole new user experience for the next version of the application. So I only hope Oracle lives up to the current road map and plans and deliver a kick ass platform with all the proposed widgets and finally what seems like JWebpane.

Oracle make us proud.

Rethinking Swing Development

I just got wind of this awesome upcoming project called Swing Query (squery), a Java implementation of a framework similar to the JQuery library for javascript. The author of the project provides some interesting examples of the potential of making Swing development a lot more fun, using a syntax similar to JQuery.

Check it out here: