Tuesday, 30 March 2010

Out West - On the Bikes

A lovely Spring day saw us off on the bikes to Shardlow. The route through Beeston, Chilwell, Attenborough and Long Eaton though not scenic (but easy going -apart from the 15mph headwind) took us first to Trent Locks, for tea and scones at the quaint tea rooms and then onto Shardlow via Church Wilne and a footbridge. It is over 7 years since I visited the canal tea rooms with my CTC biking buddies, but after a small amount of detective work (after all - they had to be along the canal somewhere) we found them.

The way back, from Trent locks to Nottingham along the Canal path was scenic and easy, the wind that so resisted us on the outward journey, now pushed us homeward.

Back at 1730 we had covered a total distance of 34 miles and averaged over 10mph.

Wednesday, 17 March 2010

How To Change the Default Icon With The Swing Java Application Framework

Since I have been out of work I have been usefully relearning my old Java skills and catching up on some of its new features.

Anyway this morning I have been struggling with how to change the default icon for the application from the boring old Coffee Cup.

In normal applications the way to do this is simply
setIconImage( Toolkit.getDefaultToolkit.getImage("full image file name"));
in your JFrame constructor.

With the java Swing application framework you have to..
  1. Copy the image into the resources directory.
  2. Find the properties file for your main View class.
  3. Add a key, something like iconImage=my short filename (i.e. just the filename without the path.)
  4. Then add the following code to the start of the constructor for your view..
    Image img = (Image)getResourceMap().getObject("iconImage",Image.class);
    getFrame().setIconImage(img);
Anyway, it took me an hour or so to work that out this morning, and many of the answers on the Java forums seemed nothing short of useless. I hope therefore, that this post comes in handy to all those budding Java programmers out there.