J2ME HelloWorld

xiaoxiao2021-03-06  41

After configuring the Eclipse WTK2.2 environment. Implement the HelloWorld word on the mobile emulator

Import javax.microedition.midlet. *; import javax.microedition.lcdui. *;

// Canvas, it implements the contents of the display mobile phone screen Class Hellocanvas Extends Canvas {public hellocanvas () {}

Public void Paint (Graphics G) {G.SetColor (255, 255, 255); g.FillRect (0, 0, getWidth (), getHeight ()); g.setcolor (0, 0, 0); g.drawline (10, 10, 50, 50); g.drawstring ("Hello World!", 0, 0, Graphics.Left | graphics.top);}}

// midlet program entry, display Canvas Public Class HelloWorld Extends MIDlet ImmandListener {Private Hellocanvas Canvas_; Private Display Display_;

Public helloworld () {canvas_ = new hellocanvas ();

Public void startapp () {display_ = display.getdisplay (this); display_.setcurrent (canvas_); canvas_.repaint ();}

Public void pauseapp () {}

Public void destroyApp (boolean unconditional) {}

Public void CommandAction (Command C, Displayable S) {}}

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

New Post(0)