Java Reference
In-Depth Information
Figure 2-3. Jargoneer's TextBox
TextBox is a text input field. It has a title and an area for entering text. It has a simple design
and can easily be shown on screens of different sizes. Even more interesting are the commands
that appear at the bottom of the TextBox . These are Exit and Find . The code that creates the
TextBox and its commands is in Jargoneer 's constructor:
mExitCommand = new Command("Exit", Command.EXIT, 0);
mFindCommand = new Command("Find", Command.SCREEN, 0);
// ...
mSubmitBox = new TextBox("Jargoneer", "", 32, 0);
mSubmitBox.addCommand(mExitCommand);
mSubmitBox.addCommand(mFindCommand);
mSubmitBox.setCommandListener(this);
Notice how the commands are created. You specify only a label and a type, and you register
an event listener to find out when the commands are invoked. This is purposely vague—it leaves
the implementation considerable latitude in deciding how commands should be displayed
and invoked. In Sun's J2ME Wireless Toolkit emulator, for example, TextBox shows its commands
at the bottom of the screen and allows the user to invoke them using soft buttons. Another
device might put both commands in a menu and allow the user to invoke them using a selector
wheel or some other mechanism. This is an example of the typical tradeoff between portability
(the ability to run the application across multiple MIDP implementation) and precise control.
The Likelihood of Server-Side Components
The Jargoneer example connects to a web server, sends a request, and receives a response. The
web server is actually an intermediary—it connects to the real Jargon File server, makes a
request, parses the result, and sends the stripped-down definition back to the MIDP device.
 
Search WWH ::




Custom Search