Java Foundation Classes and Swing
|Figure 9.: With 11 menus, this application would never be usable on SavaJe in normal screen mode. The menu labels are so overlapped so as to be unreadable.|
I performed two test applications in this review to demonstrate SavaJe's handling of the JFC and Swing component libraries of J2SE.
The code in Listing 6
(SwingDemo1.java) composes an application with a menu bar, menus, menu items, and a toolbar. I included 11 menus in the menu bar, just to see what would happen. As you can see in Figure 9
, SavaJe tried to display all the menus in the menu bar, but when there are too many to display in the available space, it overlays them on top of one another, abbreviating their labels until they all fit.
|Figure 10.: In virtual screen mode only, SavaJe was able to convert and display the application's 11 menus, without causing UI headaches.|
Obviously, 11 menus is too many for the normal screen mode; the names of the menus cannot be read. If you intend for users to use your application in normal screen mode, you will have to ensure that your J2SE applications are limited to only four or five menus. However, if the user rotates the screen by 90 degrees, the interface can accommodate six or seven menus. However, the virtual screen mode works perfectly well (see Figure 10
In Listing 7
(SwingDemo2.java), I wanted to write an application that would test SavaJe's deftness in using colors with J2SE. Figure 11
shows the deployed code from Listing 7
: the application starts with a simple button ("Change Color").
You can change the color of the screen through a pop-up menu (shown as a box of three radio buttons in Figure 11) that appears if you hold down the pen anywhere on the screen for a few seconds. Once the pop-up menu has appeared, you can choose one of the three colors.
|Figure 11.: This simple Swing-based application, which allows the user to change the background color of the application on-the-fly, worked just fine in SavaJe.|
You can also change color of the screen by pressing the "Change Color" button. Pressing the button launches the color-picker dialog box (not shown in Figure 11
), which is a standard JColorChooser class of JFC. Selecting a color and pressing OK on the color-picker dialog box, will change the color of background on the application's main screen. The application worked perfectly well in SavaJe; no problems or issues were detected.
>Recall that in earlier tests with AWT classes, pop-up menus did not work with text fields. However, the menu in this application worked just fine, probably because this time I explicitly handled the pop-up event and drew the menu myself.