The output window
in the Wireless Toolkit will display where the project source directory is
located (see Figure 3.5).
Table 3.1 Project Name and MIDlet Class Name for the Sample Application
Project Name MIDlet Class Name
HelloServer com.jabwt.book.HelloServer
HelloClient com.jabwt.book.HelloClient
Simple JABWT Application 45
Before showing the JABWT code, the BluetoothMIDlet class is
introduced. HelloClient and HelloServer use this class as a building
block. BluetoothMIDlet starts a processing thread and destroys the
MIDlet when a Command is selected. (The following class must be placed
in each project source directory in this book since it is reused by each
chapter in this book.)
package com.jabwt.book;
import java.lang.*;
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.bluetooth.*;
public class BluetoothMIDlet extends MIDlet implements
Runnable, CommandListener {
public BluetoothMIDlet() {}
/**
* Starts a background thread when the MIDlet is
* started.
*/
public void startApp()
throws MIDletStateChangeException {
new Thread(this).start();
Figure 3.5 The Sun Java Wireless Toolkit after creating the HelloServer project.
46 Chapter Three: High-Level Architecture
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void run() {}
/**
* Destroys the MIDlet when a Command occurs.
Pages:
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89