When developing graphical user interfaces (GUI) with Java Swing one tends to stumble upon surprising effects and problems, often wondering about the cause behind the effect. Ignoring background mechanics like database integration or the modelling of business logic, the effects in question regard windows and components right in front of you: the part of the software that the user will actually see and look at. To illustrate this further a simple but effective test-application was written that for all intents and purposes compares to applications out in the real world – allowing for enough room to optimize while making it easy to investigate the phenomena.
Thinking Out of the Box
Posts Tagged ‘Java’
This article is intended for developers that are creating and/or maintaining applications with a Java Swing based GUI. Though JavaFX is being pushed as the “new Swing” nowadays, Swing is still around.
Look & Feels are inextricably linked with every Swing application. Even if none is used explicitly, every time, a Swing based GUI is created, a Look & Feel cares about the look and (you may guess it) the feel of what you see and interact with on the screen.
A Look & Feel – so its official title says – is pluggable. This means you can plug a new or different one to your application (strongly simplified, as this actually goes down to the level of a single
JComponent). You may now ask: “But why should I care, if I do not change the Look & Feel now?” In an ideal world, you would not need to care. But, as often when using something, there are contracts.
This is what this article is about. I want to point out why you should care and develop or even maintain your Java Swing GUI or custom component with the pluggable Look & Feel technology in mind.
A Java™ developer who is used to developing GUIs with Swing and who is now trying to get into Android might be surprised: Java is not the same on Android.
The fact that Java is different on Android has been discussed in some blogs on the net already, so I just sum it up to this: Android applications can be written by any developer who knows the Java programming language. But the number of available runtime classes on Android is different: there are fewer classes in Android regarding package
java.* compared to Sun Java Standard or Micro Edition. The most surprising fact for a Java GUI developer might be that there is no Swing on Android.
This article demonstrates some aspects of how a simple Java Swing application with a nice Look and Feel was transferred to Android. The main focus is set on how to write the application with the Android SDK and the styling and theming abilities of Android.
More and more operating systems use a border resembling frosted glass for their windows, like, e.g., the Aero Glass® decoration known from Windows Vista® and Windows 7®. Providing this ‘special effect’ on the Java™ platform is still not easy to realize. Most Look and Feels use opaque borders, which do not visually match the surrounding designs of these operating systems.
This article describes a pragmatic approach to solve to this problem.