 |
|
 |
Zaurus User Group FAQs (frequently-asked questions)
|
|
Category: Main -> Zaurus Java FAQ -> User Interfaces
Answer |
· What should I consider when making a GUI for the Zaurus?
- Writing GUIs for the Zaurus must take three important aspects into consideration. The lack of a mouse, the small screen size and the very limited amount of memory available.
The lack of a mouse means that you will get no MouseEntered or MouseExited events and therefore no Tooltips or rollover effects.
The small screen size is perhaps the more important factor when designing an application for the Zaurus. Information that could have fitted on one screen on a normal sized screen now has to be distributed amongst several forms. You can achieve this using CardLayouts or TabbedPanes, bearing in mind that with each additional component you add will increase your memory footprint.
Back to top
|
· Any tips for creating my application's icon?
- Certainly! To begin with, some requirements:
* Size: 32x32, with convention insets being top=2,left=2,bottom=3,right=3
* Shadow: Icons provided by default have a 3 pixel SE drop shadow (within the insets)
* Depth: 24bpp
* Format: PNG, with alpha channel
The insets usually contain the drop-shadow in the south-eastern direction. The drop-shadow is a black underlay with an alpha gradient - easily obtained in Gimp.
Back to top
|
· How can I make use of the button in my application?
- This button is equivalent to the close window button on all other platforms, and as such it requires the same handling. Thanks to didge for the really constructive comments and information:
Since memory is expensive, creating a listener to close a frame is wasteful. Instead, I would suggest creating a subclass of Frame with the desired behavior:
public class MyFrame extends Frame
{
public MyFrame()
{
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
}
protected void processWindowEvent(WindowEvent e)
{
if(e.getID() == WindowEvent.WINDOW_CLOSING)
System.exit(0);
}
}
The above raises the point that too often listeners are used when subclassing and using processEvent would eliminate extraneous object creation, not to mention would perform faster as well. Note that using a listener not only means you have to have a the listener, but AWT use the AWTEventMulticaster which incurs additional overhead. But of course, this is an optimization for where it's appropriate.
Usual (desktop) way of doing things:
Frame myFrame = new Frame("SomeTitle");
myFrame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
Back to top
|
· What fonts can I use on the Zaurus?
- Qtopia as installed on the Zaurus does not support TrueType fonts, so only prerendered fonts in the .qpf format (See Font Issues) can be used.
Additionally, Jeode on the Zaurus has broken generic font support so that font names must be explicitly specified. For instance, using the smoothtimes font preinstalled on the Zaurus, one would create a font thusly:
Font f = new Font("smoothtimes", Font.PLAIN, 10);
Fonts that come preinstalled on the Zaurus are:
* "fixed"
* "helvetica"
* "micro"
* "smallsmooth"
* "smoothtimes"
You can also create your own fonts, or convert TTF fonts, see the Font Issues faq entry for more information.
Back to top
|
· (Font Issues) How can I use fonts on the Zaurus when using Jeode?
- You can get around the problem of the supplied Jeode VM on the Zaurus not recognising fixed width fonts by using the font's proper name, for example:
Font f = new Font("fixed", Font.PLAIN, 10);
TrueType font support isn't compiled into Qtopia for the Zaurus so you have to use what's already there in /opt/QtPalmtop/lib/fonts/*.qpf, or you have to provide your own by using the qpf build tools present in the Qtopia source distribution (Trolltech, qpf fonts defined).
Using the above for custom fonts, you would create your qpf font, place it in the /opt/QtPalmtop/lib/fonts directory on the Zaurus and use the following code:
// Assuming the font is named kanjifont_100_50_t10.qpf
Font f = new Font("kanjifont", Font.PLAIN, 10);
Back to top
|
· How can I use the GridBagLayout on the Zaurus?
- The multiple-argument consstructor of GridBagConstraints used by GridBagLayout only became public with Java 1.2. To make use of it under PersonalJava1.2/Java 1.1, you need to resort to the following ploy:
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx=1;
gbc.gridy=10;
... //access private fields directly
SomeContainer.add(SomeButton,gbc);
gbc.gridx++;
SomeContainer.add(SomeLabel,gbc);
The GridBagLayout makes a copy of the constraints passed to it via the add method and uses that to layout the button/label or Component. Because a copy is used internally by the layout, you're free to keep on modifying your version for subsequent layout additions.
Please note that GridBagLayout uses floating-point math operations heavily1, is a complex layout and as such will be less performant than a simpler, integer-based one.
Back to top
|
|
|
|
 |