Developing basic Java skills
After writing a little application in NetBeans to process Devonshire MS collation data into TEI format, I'm continuing my Java education by learning a few more things that aren't strictly relevant to that project. With Cocoon, eXist and Juxta written in Java, it makes sense to develop skills in this area, and with Java 1.6 and the latest NetBeans IDE, the tools are now mature and the platform is pretty solid.
Today I was learning how to manipulate resources such as images as part of the application. In the IDE, and when running the app in its debugger, there seems to be no actual JAR file, so images can only be loaded from the file system; however, when you build the JAR, any images are bundled into the JAR, and then you need to use different code to get at them. In order to have an app that runs correctly in the IDE and as a JAR file, therefore, you need to allow for both contingencies, so I have code that looks like this:
File iFile = new File("images/smiley.png"); if (iFile.exists()){ setIconImage(new ImageIcon("images/smiley.png").getImage()); } else{ setIconImage(new ImageIcon(getClass().getResource("images/smiley.png")).getImage()); }
to set the icon for the application's main form.
I've also been researching the possibility of using SVG images instead of regular bitmaps as application widget icons (on toolbars etc.). This project makes use of Batik to render SVG images in a scalable fashion in a Java UI. This is really worth looking at. Right now, my Windows apps use 12 different versions of each glyph image to allow four sizes and three states; this system might allow me to use just one image, and let the user scale it exactly how they like.