Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Run Big Java Apps on Small Devices  : Page 2

Sure enough—you can run full-fledged J2SE applications on small devices. SavaJe OS for the Pocket PC can let your users run Java apps on their wireless devices and free you from the burden of porting them to the J2ME. Find out just how much you can expect from this first-of-its-kind product.


advertisement
AWT Performance
Working with Flow Layout
I started my tests with the flow layout because it is the simplest and one of the most primitive methods of GUI implementation in AWT. Listing 1 (AWTDemo1.java) is a flow layout-based AWT GUI. The application contains labels, text fields, check boxes (both independent and grouped), buttons, and a drop-down list. Figure 1 shows my flow layout demo app running in normal mode on the iPAQ. Figure 2 shows the same in virtual screen mode. To see how SavaJe modified the application interface, you can compare Figure 1 with what appears on the screen of a desktop when you run the code in Listing 1.

SavaJe handled the layout of the components exactly as I expected. Flow layout imposes no restriction on placement of components, therefore SavaJe simply puts them where it can on the small screen.

Author's Note: In normal mode, SavaJe users can rotate the screen by 90, 180, or 270 degrees. This means users can effectively switch the horizontal and vertical axes. All screen shots in this review except Figure 2 show a virtually square screen. But the actual device screens are normally rectangular. There is a small, touch-sensitive keyboard (which my screen capture method didn't show on the images) on the device screen just below the application interface. Therefore, the screen is actually rectangular—there is more vertical space than there is less horizontal space. If you switch the two axes, you can gain more horizontal real estate on the screen. Only Figure 2 was shot with the screen rotated into this horizontal orientation.

As you can see in Figures 1 and 2, SavaJe gave the components the look and feel of JFC instead of AWT. In my tests, the entire suite of AWT components looked like JFC components on the SavaJe screen. This is probably because SavaJe's engineering team wanted to keep the footprint of the J2SE implementation small and thus decided not to duplicate the look and feel of components. Implementing AWT and JFC with the same look and feel helps keep the product small and efficient. However, it shouldn't bother Java developers too much. In fact, most Java applications built today prefer the JFC GUI over AWT, so having AWT components look like JFC components can be seen as ad advantage.

Figure 1.: A flow layout application in normal screen mode. Figure 2.: A flow layout application in virtual screen mode.

I noticed one important behavior missing on SavaJe. In most operating systems, right-clicking on a text field launches a pop-up menu for copy/cut/paste and a few other standard operations. The equivalent event of right-clicking on text in SavaJe is to hold down the pen on the screen for a few seconds. But in my tests, the right-click (pop-up menu) event never occurred.

Working with Grid Layout
The demo application in Listing 2 (AWTDemo2a.java) uses the Frame class of AWT as the main GUI (top-level) window. It creates a 4x1 grid layout and adds four panels to it, each of which contains different AWT components. The completed grid is added as the Northern component of the Frame-based GUI window. Figures 3 and 4 show the grid layout in normal and virtual screen modes, respectively.



Figure 3.: Depicted is a grid layout application in normal screen mode. Figure 4.: Depicted is a grid layout application in virtual screen mode.

All the observations that I made earlier about the flow layout application in Listing 1 are valid for this application as well. Components were displayed as I expected. In addition, I made an interesting observation that might be useful if you decide to develop for this platform: The text field in which to enter an employee name was set at 20 characters. Because of its length and the lack of horizontal space in a single cell of a 4x1 grid, SavaJe displayed the text field underneath its label ("Employee") instead of beside it (see Figure 3). When I reduced the size of the text field from 20 characters to 15 characters, it became small enough to fit next to the "Employee" label on the same line (see Figure 5).

Listing 3 (AWTDemo2b.java) is similar to Listing 2 (AWTDemo2a.java) except that this application contains two 4x1 grids. One of the two grids is positioned as the Western component of the main frame of our GUI and the other is positioned as the Eastern component. This gives you an idea of how much lateral space is available on the small SavaJe screen (see Figure 6).

Figure 5.: By reducing the number of characters in the Employee text field from 20 to 15, SavaJe was able to display both the text field and label components on the same line. Figure 6.: Depicted is a grid layout application, built with two 4x1 grids, set in a horizontal configuration, in normal screen mode.

In contrast to Listing 2, this time the 20-character text field appeared without any distortion. Placing a grid as a Western component makes the J2SE classes think that there is more vertical space to work with for drawing on the screen. However, as you can see in Figure 6, the whole Eastern block that is supposed to reside to the right has been clipped off.

Listing 4 (AWTDemo2c.java) and its associated screen shot (Figure 7) depict the same two components, but this time the grids are positioned as Northern and Southern panels on the main frame. Everything is the same as it was before except that, once again, the 20-character text field does not appear properly in normal screen mode—it appears beneath, instead of adjacent to, its label. It has also been compressed vertically, making it virtually useless for character entry. This happened several more times when working with test apps in a vertical configuration in the normal screen mode.

Figure 7.: Depicted is a grid layout application, built with two 4x1 grids, set in a vertical configuration, in normal screen mode. Figure 8.: Depicted is a 4x1 grid control along with a text area and a list in normal screen mode.

Next I tried to squeeze some larger components on the screen. Listing 5 (AWTDemo2d.java) and its associated screen shot (Figure 8) places the same list and text areas as before on the screen, in addition to the entire 4x1 grid. Note that the scroll box component in the lower right quadrant is not displayed optimally. The left edge of the text in the scroll box (about two characters' worth) is clipped off.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap