Top Banner
Programmation J Programmation J2ME ME 1
15

Programmation J2ME - Kamel Aloui · public class Midlet_1 extends MIDlet implements CommandListener private Display display; // Reference to Display object for this MIDlet private

Feb 09, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Programmation J2ME - Kamel Aloui · public class Midlet_1 extends MIDlet implements CommandListener private Display display; // Reference to Display object for this MIDlet private

Programmation JProgrammation J22MEME

1

Page 2: Programmation J2ME - Kamel Aloui · public class Midlet_1 extends MIDlet implements CommandListener private Display display; // Reference to Display object for this MIDlet private

Activité 1Activité 1

2

Page 3: Programmation J2ME - Kamel Aloui · public class Midlet_1 extends MIDlet implements CommandListener private Display display; // Reference to Display object for this MIDlet private

ActivitéActivité 11

3

Page 4: Programmation J2ME - Kamel Aloui · public class Midlet_1 extends MIDlet implements CommandListener private Display display; // Reference to Display object for this MIDlet private

ActivitéActivité 11

4

Page 5: Programmation J2ME - Kamel Aloui · public class Midlet_1 extends MIDlet implements CommandListener private Display display; // Reference to Display object for this MIDlet private

ActivitéActivité 22

5

Page 6: Programmation J2ME - Kamel Aloui · public class Midlet_1 extends MIDlet implements CommandListener private Display display; // Reference to Display object for this MIDlet private

Activité 2Activité 2

6

Page 7: Programmation J2ME - Kamel Aloui · public class Midlet_1 extends MIDlet implements CommandListener private Display display; // Reference to Display object for this MIDlet private

Activité 2Activité 2

7

Page 8: Programmation J2ME - Kamel Aloui · public class Midlet_1 extends MIDlet implements CommandListener private Display display; // Reference to Display object for this MIDlet private

Activité 2Activité 2

8

Page 9: Programmation J2ME - Kamel Aloui · public class Midlet_1 extends MIDlet implements CommandListener private Display display; // Reference to Display object for this MIDlet private

Activité 3Activité 3

9

Page 10: Programmation J2ME - Kamel Aloui · public class Midlet_1 extends MIDlet implements CommandListener private Display display; // Reference to Display object for this MIDlet private

ActivitéActivité 33

10

Page 11: Programmation J2ME - Kamel Aloui · public class Midlet_1 extends MIDlet implements CommandListener private Display display; // Reference to Display object for this MIDlet private

Activité 3Activité 3

11

Page 12: Programmation J2ME - Kamel Aloui · public class Midlet_1 extends MIDlet implements CommandListener private Display display; // Reference to Display object for this MIDlet private

ActivitéActivité 33

12

Page 13: Programmation J2ME - Kamel Aloui · public class Midlet_1 extends MIDlet implements CommandListener private Display display; // Reference to Display object for this MIDlet private

Activité 1import javax.microedition.midlet.*;import javax.microedition.lcdui.*;

public class Midlet_2 extends MIDlet implements CommandListener {// The exit commandprivate Command exitCommand;// The display for this MIDletprivate Display display;// create a tickerprivate Ticker hi = new Ticker("J2ME is cool");

public Midlet_2() {display = Display.getDisplay(this);exitCommand = new Command("Exit", Command.SCREEN, 2);

}

public void startApp() {TextBox t = new TextBox("Hello MIDlet", "Wireless Internet", 256, 0);t.addCommand(exitCommand);t.setCommandListener(this);t.setTicker(hi); // set the tickerdisplay.setCurrent(t);

}public void pauseApp() { }public void destroyApp(boolean unconditional) { }public void commandAction(Command c, Displayable s) {if (c == exitCommand) {destroyApp(false);notifyDestroyed();

}}

}

13

Page 14: Programmation J2ME - Kamel Aloui · public class Midlet_1 extends MIDlet implements CommandListener private Display display; // Reference to Display object for this MIDlet private

Activité 2import javax.microedition.midlet.*;import javax.microedition.lcdui.*;

public class Midlet_1 extends MIDlet implements CommandListener{private Display display; // Reference to Display object for this MIDletprivate Form fmMain; // The main Formprivate TextBox tbAction; // Textbox to show when user selects upload/downloadprivate Command cmExit; // Exit the MIDletprivate Command cmBack; // Go "back" to the main formprivate Command cmUload; // "upload" data - no real action doneprivate Command cmDload; // "download" data - no real action done

public Midlet_1(){

display = Display.getDisplay(this);cmExit = new Command("Exit", Command.EXIT, 1);cmBack = new Command("Back", Command.BACK, 1);cmUload = new Command("Upload", Command.SCREEN, 2);cmDload = new Command("Download", Command.SCREEN, 3);// Create the Form, add Commands, listen for eventsfmMain = new Form("Core J2ME");fmMain.addCommand(cmExit);fmMain.addCommand(cmUload);fmMain.addCommand(cmDload);fmMain.setCommandListener(this);// Create a Textbox, add Command, listen for eventstbAction = new TextBox("Process Data", "Upload/download data ", 25, 0);tbAction.addCommand(cmBack);tbAction.setCommandListener(this);

}// Called by application manager to start the MIDlet.public void startApp(){

display.setCurrent(fmMain);}// A required methodpublic void pauseApp(){ }// A required methodpublic void destroyApp(boolean unconditional){ }// Process eventspublic void commandAction(Command c, Displayable s){

if (c == cmExit){

destroyApp(false);notifyDestroyed();

}else if (c == cmUload || c == cmDload)

display.setCurrent(tbAction);else if (c == cmBack)

display.setCurrent(fmMain);}

}

14

Page 15: Programmation J2ME - Kamel Aloui · public class Midlet_1 extends MIDlet implements CommandListener private Display display; // Reference to Display object for this MIDlet private

Activité 3import javax.microedition.midlet.*;import javax.microedition.lcdui.*;

public class Midlet extends MIDlet implements ItemStateListener, CommandListener{private Display display; // Reference to Display object for this MIDletprivate Form fmMain; // The main Formprivate Command cmExit; // A Command to exit the MIDletprivate DateField dfDate; // Display the date

public Midlet(){

display = Display.getDisplay(this);// Create the date and populate with current datedfDate = new DateField("Date is:", DateField.DATE);dfDate.setDate(new java.util.Date());cmExit = new Command("Exit", Command.EXIT, 1);// Create the Form, add Command and DateField// listen for events from Command and DateFieldfmMain = new Form("Core J2ME");fmMain.addCommand(cmExit);fmMain.append(dfDate);fmMain.setCommandListener(this); // Capture Command events (cmExit)fmMain.setItemStateListener(this); // Capture Item events (dfDate)

}// Called by application manager to start the MIDlet.public void startApp(){

display.setCurrent(fmMain);}

public void pauseApp(){ }

public void destroyApp(boolean unconditional){ }

public void commandAction(Command c, Displayable s){

if (c == cmExit){

destroyApp(false);notifyDestroyed();

}}

public void itemStateChanged(Item item){

System.out.println("Inside itemStateChanged()");dfDate.setLabel("New Date: ");

}}

15