09 display
Post on 21-Jun-2015
230 Views
Preview:
TRANSCRIPT
Display
Cornelius Koo – 2005cornelius.mellino@gmail.com
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
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.
public class HelloWorld extends MIDlet {
private Display display;
public HelloWorld() {
super();
display = Display.getDisplay(this);
}
…
Display API
Example MIDlet : TestDisplay.java
Displayable
The Rules
• There is only one Display object per
MIDlet.
• Display object can show any number of
Displayable objects.
There are two class that extends Displayable. Those are
Canvas and Screen classes.
Creating Displayable Class
1. Extends Canvas class directly.
2. Use subclasses of Screen.
3. Extends from subclasses of Screen.
Extends Canvas Class Directly
public class MyOwnScreen extends Canvas
{
Drawing something…
}
Use Subclasses of Screen
TextBox t = new TextBox(
"Hello World MIDlet",
"Hello Small World", 256, 0);
...
display.setCurrent(t);
Extends From Subclasses of Screen
public class MyForm extends Form { }
Displayable API
Example MIDlet : TestDisplayable.java
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.
top related