Looking back at Swing


I am currently using a Java third party library that uses Swing classes. I had to perform a simple task today, which included creating a Label with an Icon, using Swing’s ImageIcon class. I looked into swing six years ago. Then, at the time I was the first Flex person in a Java developer’s team. The company I was working for was switching from Swing to Flex. It is interesting to look at Swing and learn how the concept of productivity in a GUI development environment has changed over such a short time period. For instance, this is how the Swing manual suggests that you create a label with an Icon:

<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%">ImageIcon icon = createImageIcon("images/middle.gif",
"a pretty but meaningless splat");
label1 = new JLabel("Image and Text", icon, JLabel.CENTER);
...
label3 = new JLabel(icon);

/** Returns an ImageIcon, or null if the path was invalid. */
protected ImageIcon createImageIcon(String path,
String description) {
java.net.URL imgURL = getClass().getResource(path);
if (imgURL != null) {
return new ImageIcon(imgURL, description);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}
</pre>Can you imagine? All this code is required for a simple Label with an Icon! Software
development has changed in the last few years. Platforms and languages are expected to be more efficient and require less code and time from the developer.

Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com