Programming Tutorials

(追記) (追記ここまで)

StringItem sample program in J2ME

By: Kamini in J2ME Tutorials on 2007年09月16日 [フレーム]

Here is a sample program in J2ME that demonstrates the usage of the StringItem class:

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.midlet.MIDlet;
public class StringItemDemo extends MIDlet {
 private Display display;
 public StringItemDemo() {
 display = Display.getDisplay(this);
 }
 public void startApp() {
 Form form = new Form("StringItem Demo");
 StringItem hello = new StringItem(null, "Hello World!");
 StringItem description = new StringItem(null, "This is a StringItem demo.");
 form.append(hello);
 form.append(description);
 display.setCurrent(form);
 }
 public void pauseApp() {
 }
 public void destroyApp(boolean unconditional) {
 }
}

In this example, we create a Form object and append two StringItem objects to it. The first StringItem displays the text "Hello World!" and the second StringItem displays the text "This is a StringItem demo.". We then set the Form as the current display using the setCurrent() method of the Display object.

When this application is run on a J2ME-enabled device, it will display a screen with the two StringItem objects showing their respective texts.




(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!
(追記) (追記ここまで)
(追記) (追記ここまで)

AltStyle によって変換されたページ (->オリジナル) /