Determining Event KeyCode on Mobile Browser (Chrome, Android, Firefox)

Recently, I run into a very common issue with regards to determining the Event KeyCode when entering text into a textarea on a mobile device. This had me scratching my head for a good couple of hours, but eventually I managed to get a solution that works perfectly well on desktop and mobile for the same piece of code. Continue reading “Determining Event KeyCode on Mobile Browser (Chrome, Android, Firefox)”

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();
   rect.setFill(Color.RED);
   rect.setWidth(200);
   rect.setHeight(100);
   rect.setX(20.0f);
   rect.setY(20.0f);

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.

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.

Node.js on Windows: Who Needs NPM?

So last night via DZone I get word that Node.js had released a Windows version of the popular Javascript based server environment around the 14th of July. Checking from their site, version 0.5.2 was out, being the second currently unstable release for Windows at the moment. I could not hold back my excitement as I do not run Linux, and we use Node.js extensively in my workplace. I just had to try it.

Setting It Up

So in a matter of minutes, the 9.8MB “node.exe” download was on my system, and without even reading any blogs or instructions, I just knew I had to  setup my Windows CMD Environment variables to point to this executable so I could use it from any folder I wished.

And just like a typical Ghanaian who does not read instructions, I jumped straight at the opportunity to run our socket server we were using in the project. That is when all hell broke loose, at least for a few minutes.

The culprit? Missing packages and libraries. I half expected that, just wanted to try without them for the fun of it.

So the next step, find and download the needed libraries. What are they? Just two actually,

  1. Node MySQL Native
  2. Socket.io

Easy peasy, so how do you download them for use by Node on Windows? In Linux I would setup NPM (Node Package Manager) and easily execute a call like

npm install mysql

to get a mysql package from the online repo. But I don’t have NPM on Windows, because apparently the current  version does not support child_process.spawn. That’s a bummer. So how do you do get it run.

The Steps

  1. Download the required package directly from the github repo in .zip format
  2. Place it in the same folder as the node.exe executable
  3. Unpackage the archive and rename the contained folder it as it would have been named if it were to be downloaded via npm. In the case of the mysql package, I renamed the folder from “felixge-node-mysql-6a40e53” to simply “mysql”.
  4. That’s all

Who needs NPM on Windows. Here are the packages downloaded

Btw, I had issues when trying to install socket.io. Apparently, our company is running version 0.6.2 and the current version from the repo is 0.7.7 which depends on three extra packages in order to run. I had to revert and download the 0.6.2 package in order for things to work.

Happy Node Development y’all!

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: http://squery.posterous.com/