Java Reference
In-Depth Information
to focus instead on the behavior of the UI components we have described
in so much detail.
To get started, open theWTK and create a new project, called UIExam-
pleMIDlet . Our application has two classes in the example package:
UIExampleMIDlet (the main class) and MenuCanvas .
UIExampleMIDlet Class
Class UIExampleMIDlet
package example;
Import list omitted for readability
public class UIExampleMIDlet extends MIDlet implements CommandListener {
private Form form = null;
private List list = null;
private TextBox textBox = null;
private Canvas canvas = null;
private TextField textField = null;
private DateField dateField = null;
private Alert alert = null;
private ChoiceGroup choiceGroup = null;
private StringItem stringItem = null;
private Image image = null;
private ImageItem imageItem = null;
private Command backCommand = null;
private Command exitCommand = null;
private Ticker ticker = null;
private Gauge gauge = null;
public UIExampleMIDlet() throws IOException {
// creating commands
backCommand = new Command("Back",Command.BACK,0);
exitCommand = new Command("Exit",Command.EXIT,0);
// creating Form and its items
form = new Form("My Form");
textField = new TextField("MyTextField","",20,TextField.ANY);
dateField = new DateField("MyDateField",DateField.DATE_TIME);
stringItem = new StringItem("MyStringItem","My value");
choiceGroup = new ChoiceGroup("MyChoiceGroup",Choice.MULTIPLE,
new String[] { "Value 1","Value 2","Value 3" } , null);
image = Image.createImage("/test.png");
imageItem = new ImageItem("MyImage",image,ImageItem.LAYOUT_CENTER,
"No Images");
gauge = new Gauge("My Gauge",true,100,1);
Search WWH ::

Custom Search