In the Motorola phone, in the primary class, respond to the button message in other classes.

zhaozj2021-02-17  52

See the program:

// File name LWTDemomidlet.javaImport com.motorola.lwt. *; Import javax.microedition.lcdui. *; Import javax.microedition.midlet. *;

Public class lwtdemidlet extends midlet imports commandlistener {class button {

Public buttonscreen () {

// add a button to the screenbutton b1 = new button ("b"); /// The following code is the setting button height b1.setbottomedge (Component.Height, 30); /// The following code is the setting button Width b1.serightedge (Component.width, 80);

/// The following code is the setting button Y coordinate, and a relative screen is the top

B1.SETTOPEDGE (Component.Screen_top, 10);

/// The following code is the setting button X coordinate relative to the previous control b1.setleftedge (Component.Previous_component_Right, 30);

Add (b1);

// add another button to the screenbutton but = new button ("Point I will line") {public void componentactuated () {show ();}}; // extend the right edge to the right edge of the screenb2.seRightetedge Component.width, 220); b2.setbottomedge (Component.Height, B2.GetPreferredHeight () * 2); add (b2); command next = new command ("next", command.ok, 1); command prev = New Command ( "Previous", Command.BACK, 1); addCommand (next); addCommand (prev);}}; ButtonScreen screens = new ButtonScreen (); public LWTDemoMIDlet () {screens.setCommandListener (this);} protected void startApp () throws MIDletStateChangeException {Display.getDisplay (this) .setCurrent (screens);} protected void pauseApp () {} protected void destroyApp (boolean unconditional) throws MIDletStateChangeException {} public void Show () {System.out.println ( "Get IT on main class ");} public void command (Command C, Displayable D) {

IF (Screens == D) {// Found IT, Check Which Command Was Triggeredif (c.getCommandType () == Command.back) {system.out.println ("back");} else if (C.GetCommandType ) == command.ok) {system.out.println ("ok");} return;}}} JCReater Pro

Motosdk compilation

转载请注明原文地址:https://www.9cbs.com/read-29229.html

New Post(0)