09 display

15
Display Cornelius Koo 2005 [email protected]

Upload: corneliuskoo

Post on 21-Jun-2015

230 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: 09 Display

Display

Cornelius Koo – [email protected]

Page 2: 09 Display

What is Display

• The Display object working just like a

manager of the display controlling what is

shown on the device and when.

• javax.microedition.lcdui.Display

Page 3: 09 Display

How to Get

• Display object is made available to MIDlet

through a call to static method declared

inside the Display class.

• The reference is often held for a lifetime of

MIDlet.

Page 4: 09 Display

public class HelloWorld extends MIDlet {

private Display display;

public HelloWorld() {

super();

display = Display.getDisplay(this);

}

Page 5: 09 Display

Display API

Page 6: 09 Display

Example MIDlet : TestDisplay.java

Page 7: 09 Display

Displayable

Page 8: 09 Display

The Rules

• There is only one Display object per

MIDlet.

• Display object can show any number of

Displayable objects.

Page 9: 09 Display

There are two class that extends Displayable. Those are

Canvas and Screen classes.

Page 10: 09 Display

Creating Displayable Class

1. Extends Canvas class directly.

2. Use subclasses of Screen.

3. Extends from subclasses of Screen.

Page 11: 09 Display

Extends Canvas Class Directly

public class MyOwnScreen extends Canvas

{

Drawing something…

}

Page 12: 09 Display

Use Subclasses of Screen

TextBox t = new TextBox(

"Hello World MIDlet",

"Hello Small World", 256, 0);

...

display.setCurrent(t);

Page 13: 09 Display

Extends From Subclasses of Screen

public class MyForm extends Form { }

Page 14: 09 Display

Displayable API

Example MIDlet : TestDisplayable.java

Page 15: 09 Display

Reference

• Core J2ME Technology and MIDP. John

W. Muchow. Prentice Hall PTR, 2002.

• Enterprise J2ME: Developing Mobile

Java Applications. Michael Juntao Yuan.

Prentice Hall PTR, 2003.

• J2ME in A Nutshell. Kim Topley. Oreilly,

2002.