Kamis, Oktober 28

Praktikum ke Tiga.....

Praktikum ke tiga :
- Menginstall wireless toolkit
- Setelah menginstall maka buka wireless toolkit dengan cara : star, menu, program, toolkit
- Buat project dengan nama praktikum 3
- Setelah itu buka window explorer, buka directory C, cari folder WTK25, dan cari folder Apps
- Pada folder Apps tersebut ada nama praktikum 3 yang berisi
• Bin: jad/jar
• Lib: Library
• Res: Audio, gambar
• Src: *., java
Setelah melakukan hal diatas maka
- buka notepad
- ketikan program berikut :

- package hello;
- import javax.microedition.midlet.*;
- import javax.microedition.lcdui.*;
-
- public class HelloMIDlet extends MIDlet implements CommandListener
- {
- private boolean midletPaused = false;
-
- private Command exitCommand;
- private Form form;
- private StringItem stringItem;
-
- public HelloMIDlet() {
- }
-
- private void initialize() {
- }
-
- public void startMIDlet() {
- switchDisplayable(null, getForm());
- }
-
- public void resumeMIDlet() {
- }
-
- public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
- Display display = getDisplay();
- if (alert == null) {
- display.setCurrent(nextDisplayable);
- } else {
- display.setCurrent(alert, nextDisplayable);
- }
- }
-
- public void commandAction(Command command, Displayable displayable) {
- if (displayable == form) {
- if (command == exitCommand) {
- exitMIDlet();
- }
- }
- }
-
- public Command getExitCommand() {
- if (exitCommand == null) {
- exitCommand = new Command("Exit", Command.EXIT, 0);
- }
- return exitCommand;
- }
-
- public Form getForm() {
- if (form == null) {
- form = new Form("Welcome", new Item[] { getStringItem() });
- form.addCommand(getExitCommand());
- form.setCommandListener(this);
- }
- return form;
- }
-
- public StringItem getStringItem() {
- if (stringItem == null) {
- stringItem = new StringItem("", "Hello Midlet, Hello World!");
- }
- return stringItem;
- }
-
- public Display getDisplay () {
- return Display.getDisplay(this);
- }
-
- public void exitMIDlet() {
- switchDisplayable (null, null);
- destroyApp(true);
- notifyDestroyed();
- }
-
- public void startApp() {
- if (midletPaused) {
- resumeMIDlet ();
- } else {
- initialize ();
- startMIDlet ();
- }
- midletPaused = false;
- }
-
- public void pauseApp() {
- midletPaused = true;
- }
-
- public void destroyApp(boolean unconditional) {
- }
-
- }
- Setelah itu save as dengan nama latihan1.java dengan type :All
- Setelah itu lakukan build dan run pada wireless toolkit
- Maka akan muncul sebagai berikut:

Tidak ada komentar:

Posting Komentar