Java AutoConversion textfield component

AutoConversion textfield component:

If you drive a motorized stage of a microscope you often have to handle coordinates in a unit like millimeter [mm]. But it might happen that the sample in your microscope is only in the range of microns [µm].

So would it not be nice to directly type in the coordinates in µm and the textfield would automaticaly convert the unit into [mm] ?

This would increase the workflow a lot because you do not have to think about conversion of units. There seems to be countries that are using inches and people living there might like to type in coordinates in inches instead of millimeters..etc…

For this reason i created a little component that extends a standard javax.swing.JTextField and is now able to do the conversion. You could also use the conversion alone without the textfield to create some kind of unit converter…it’s up to you.

Here are a few screenshots of a demo app that uses the component:

#1 Step

#3 Step#2 Step

So you could type in a value with the unit of your choice and after leaving the field or pressing enter the value will be converted into the textfields „base unit“.

The upper combobox will select the type of unit you would like to use (it supports angle, area, length, mass, temperature, time at the moment but one could easily add more units to it).

The middle combobox will select the current base unit for the textfield.

The lower combobox will adjust the number of decimals for the textfield.

Because it displays the unit directly in the textfield there’s no need for a additional label for the unit.

You also might check this little video

Well this is nothing very fancy or gui related but it was very useful for me so i decided to share it with you…


follow me on twitter if you like…


Kritische Sicherheitslücke im Spring Framework

Spring Source hat mit CVE-2010-1622 auf eine kritische Sicherheitslücke im Spring Framework aufmerksam gemacht. Die von Meder Kydyraliev, Google Security Team gefundene Lücke ist seit April bekannt und wurde mit dem Release Spring Framework 3.0.3 gefixt. (Dieses Release wurde jedoch nicht als sicherheitskritisch gekennzeichnet und das Problem könnte so leicht übersehen werden!) weiterlesen


JUG SummerEvent

Am 12. Juni ist es soweit…ich werde bei mir zu Hause den inoffiziellen JUG SummerEvent veranstalten…

Dabei geht es im wesentlichen darum sich zu treffen, ein paar Bierchen zusammen zu trinken, etwas auf den Grill zu schmeissen und natürlich auch ein wenig Java zu coden (natürlich nur wer Lust dazu hat). Desweiteren steht ein Tischkicker, evtl. eine Carrerabahn (muß ich erst aufbauen) und ein Trampolin zur Verfügung für diejenigen von Euch, welche sich sportlich betätigen möchten.

Da wir bei uns zu Hause natürlich keinen geeigneten Raum haben um Vorträge zu präsentieren, würde es sich ja anbieten diesen Event für sog. Lightning Talks zu nutzen. Dabei kann jeder der Interesse hat ja etwas vorbereiten, was er den anderen in max. 10 Minuten zeigen möchte.

Ihr könnt Euch auch hier bei Xing als Teilnehmer eintragen falls Ihr mögt…


Zur Veranstaltung:

Wer: jeder der Lust und Zeit hat sich ein wenig auszutauschen

Wo: Bei mir zu Hause (Westfalenstrasse 93, 48165 Münster GoogleMaps)

Wann: ab 11 Uhr könnt Ihr bei mir eintrudeln, Ende offen

Mitzubringen sind:

– Grillfleisch

– Notebook (falls benötigt)

– wenn mögich Salate und Brot


Getränke, Grill etc. sponsor ich…



Using Smack xmpp lib on Android with Netbeans

Android + XMPP + Netbeans

Last week i got my Android phone and finally started coding for a mobile phone (which really is a great experience and lot’s of fun).

During my daylight work i’m using xmpp in different projects and tools and so i would really like to use it on the Android phone also. In the java world there is a really neat library called smack from ignite realtime which makes using xmpp a piece of cake and so i asked myself if it would also run on android?

Yes it does…BUT…you need a patched version that i found on the net…
In Eclipse it seems to be easy to link a external library to a android project but in Netbeans i was not so intuitively as i thought…
You need three little steps to include a external library like smack and here they are:

#1 STEP:

Create a local folder named „lib“ in your Android project folder like this:

lib folder in project directory

Now copy the patched smack.jar file into this folder. weiterlesen


FXG to Java2D converter


During the last months i was working a lot on Java Swing components which really is a lot of fun. It took me some time to establish a workflow to transfer my design prototypes from Adobe Fireworks into Java2D elements.

With not too complex shapes this was not a big deal even if it was a lot of coding (see also Drawing in code part I and Drawing in code part II) but during the work on my current component (which will be a combination of weather and time of day display for different cities) i needed to create clouds…

Did you ever create clouds in vector programs ? It’s really not so easy if they should look nice and you will need a lot of ellipses in different sizes to get a result which looks not too bad.
After creating my first cloud out of 49 circles (all the same size) i figured out that it would take a looooooooong time to complete these clouds. weiterlesen


Swing event departure board

Sitting at Gard du Nord train station in Paris in January this year i saw this huge departure board:


It was fascinating to see and hear all these flipping characters everytime a departure time changed. I guess most of you know already how these boards work but for all others i will explain it shortly.

The arriving trains are in chronological order from top to bottom of the board which means the trains that arrives as next stays on top of the board.
The flipping characters are made of little metal plates that are printed on the front and backside with characters that are split into half. The Top part of the character is printed on the frontside of the upper plate and the bottom part of the character is printed on the backside of the lower plate (i tried to visualize it with a little image). weiterlesen


Swing Weather Worldclock

Remember the worldclock blogpost? Well it was ok but i thought there was one thing missing…

Weather information

For that reason i added this missing feature to the known worldclock component so that you now might choose out of four clocks:

  • Pure clock and icon indicator for time of day
  • Pure clock, icon indicator for time of day and weather information
  • Clock with inbuild time of day display
  • Clock with inbuild time of day display and weather information

This image shows all available clocks:


To get the weather information for all the cities in the enum i provide, i needed to add the country for each city and by adding all these countries i translated the cities to their (hopefully) right english names (in the original worldclock post i used german city names).

I use weather underground to retrieve the weather information because they provide an easy to access service for free. You will find a package called „net“ in the project in which i put the classes responsible for fetching the weather condition. There is timer which checks every 30 seconds for the availability of the connection.
The clockpanels will every 10 minutes add a so called ConditionFetcher thread to the queue of the WeatherService which will be handled by a ExecutorService. The WeatherService will tries to use the system proxy server if there is one so it hopefuly works out for you.

The most of the work was done by creating all the different weather condition images which you will see in the next image:




Drawing in code (Part 2)

Drawing in code:

Part 2 (Transfer the prototype into swing):

So you will find out that this is not magic but only drawing the same elements that we used in the vector drawing programm but now in their Java2D representations. We just create a buffered image with the same size as the prototype. So we could use the same pixelcoordinates for the shapes and gradients in swing.


Drawing in code (Part 1)

Drawing in code:

Part 1 (Drawing the prototype):

After i published my little fun swing nixieclock i got a lot of requests on how i transferred the image into swing.
Because i remember when i was starting swing development i asked myself the same questions when i saw the amazing work of swing/design guru’s like Kirill Grouchnikov, Romain Guy, Joshua Marinacci, Chet Haase, and others.
Well in the meantime i figured out how to do this and find a workflow that i would like to share here. By the way this is really nothing compared to the things these swing/design guru’s are able to do.

So here we go, first of all i have one good advice for you „Know your tools“,
which means not only java and swing but also your graphics program.

So i’m using Adobe Fireworks for that but you could also use any other kind of graphics program like Adobe Photoshop, Gimp, Inkscape etc.

I will start the tutorial with the drawing of the tube in Adobe Fireworks because it makes coding in swing so much easier if you know how to draw it in a graphics program. So the first part will be focussed on the drawing and the second part will explain how to draw all the different points in java2d/swing: weiterlesen