Mobile UI Development with Java - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

Mobile UI Development with Java

Description:

Allows to create Java 'applications running on small devices with limited memory, ... Java ME Platform for Converged Services- covers everything! ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 35
Provided by: softin
Category:

less

Transcript and Presenter's Notes

Title: Mobile UI Development with Java


1
Mobile UI Development with Java
  • Nima Sarshar

2
Java Micro Edition
  • Java ME deals with constraints of small devices.
  • Allows to create Java applications running on
    small devices with limited memory, display and
    power capacity.

3
Elements of Java ME
  • a configuration provides the most basic set of
    libraries and virtual machine capabilities for a
    broad range of devices,
  • a profile is a set of APIs that support a
    narrower range of devices, and
  • an optional package is a set of
    technology-specific APIs.

4
Basic Configurations
  • one to fit small mobile devices called Connected
    Limited Device Configuration (CLDC)
  • one to target more capable mobile devices like
    smart-phones and set top boxes called Connected
    Device Profile (CDC).

5
Source http//java.sun.com/javame/technology/ind
ex.jsp
6
CLDC
7
Mobile Information Device Profile
  • A widely adopted example is to combine the CLDC
    with the Mobile Information Device Profile (MIDP)
    to provide a complete Java application
    environment for mobile phones and other devices
    with similar capabilities.

8
CDC
9
Connected Device Profile-CDC
  • Targets larger devices with more capacity and
    with a network-connection, like high-end personal
    digital assistants, and set-top boxes
  • Closer to the Java Platform Standard Edition (SE)

10
Java ME Platform for Converged Services- covers
everything!
11
MIDP Mobile Information Devices Profile
http//developers.sun.com/mobility/midp/articles/g
uiapis/
12
MIDP UI API (!)
  • They are all in javax.microedition.lcdui
  • High level UI
  • Screen class and its subclasses
  • Item and its subclasses
  • High-level API lets the device choose itw own
    native look-and-feel on the handset

13
Same Code of Two Devices
14
MIDP High Level UI
  • Alert (used for showing dialog boxes and
    warnings)
  • ChoiceGroup (used for showing group of checkboxes
    or radio buttons)
  • DateField (used for selecting dates and times)
  • Form (used for displaying the subclasses of Item)
  • Gauge (used to showing the progress of an
    operation or process, but it can also be used to
    represent the percent of a whole)
  • ImageItem (used for showing images in high-level
    UI applications)
  • List (used for showing lists and combo boxes)
  • StringItem (used for showing simple text strings)
  • TextBox (used for entering text)
  • TextField (an alternate method used for entering
    text)

15
Low-Level API
  • Designer now has more control, but has to take
    care of the details
  • Canvas class and derivatives
  • Graphic object

16
MIDP 2.0
  • Bridges between low and high level UI APIs
  • AnimatedImage (which allows the creation and
    rendering of animated images)
  • FileSelector (a mechanism for browsing
    directories and selecting files on the file
    system)
  • TabbedPane (a mechanism for creating and
    displaying a tabbed pane)

17
Personal Basis and Personal Profiles
  • The Connected Device Configuration (CDC) are for
    devices with power more than a phone but
  • has less than a desk top
  • High-end mobile phones and PDAs.
  • The Personal Basis Profile has a very small
    subset of the Java SE Abstract Windowing Toolkit
    (AWT) libraries.
  • No buttons, menus, list, textboxes, scrollbars,
  • The Personal Profile almost a completely
    implements AWT, and even provides support for
    applets.

18
Example Personal Profile
19
Scalable 2D Vector Graphics API - versions 1.0
and 2.0
20
3D Graphics APIs - M3G versions 1.0 and 2.0 and
OpenGL ES
21
Advanced Graphics and User Interface (AGUI)
Finally supports Swing
  • java.awt
  • java.awt.font
  • java.awt.geom
  • java.awt.image
  • java.nio
  • javax.imageio
  • javax.imageio.event
  • javax.imageio.metadata
  • javax.imageio.stream
  • javax.microedition.plaf
  • javax.microedition.agui.event
  • javax.swing
  • javax.swing.border
  • javax.swing.event
  • javax.swing.plaf
  • javax.swing.table
  • javax.swing.text
  • javax.swing.undo

22
Summary
23
More on MIDP
24
Display
  • Display
  • The Display class provides access to the physical
    screen.
  • Only one instance of the Display object is
    allowed for each MIDlet.
  • We can obtain the instance of the Display class
    by passing the MIDlet object to the static
    Display.getDisplay() method.
  • public static Display getDisplay (MIDlet m)

25
Displayable
  • Methods in Display class display Displayable
    objects to the physical screen!
  • The Displayable object represents a view of the
    screen
  • In MIDP, there is only one Displayable object
    visible at any given time.
  • setCurrent() method is used to switch the view.
  • public void setCurrent(Displayable d)
  • public void setCurrent(Alert a, Displayable d)
  • public void setCurrentItem(Item item)
  • public Displayable getCurrent()

26
Displayable
  • The Displayable class is an abstract
    representation of a full screen of display
    content.
  • We can query whether a Displayable object is
    shown on the LCD by calling its isShown() method.
  • The Displayable class allows us to query the size
    of the screen display area.
  • public int getWidth()
  • public int getHeight()
  • public boolean isShown()

27
Displayable
  • The Displayable class also provides methods to
    add and manipulate the title and ticker of the
    display area.
  • public void setTitle(String title)
  • public String getTitle()
  • public void setTicker (Ticker ticker)
  • public Ticker getTicker ()
  • A ticker is an optional line of text string
    scrolling across the top of the display area.

28
(No Transcript)
29
  • public interface CommandListener void
    commandAction(Command command, Displayable
    displayable)
  • public void addCommand(Command cmd)
  • public void removeCommand(Command cmd)
  • public void setCommandListener(CommandListener l)

30
(No Transcript)
31
Low-level API
  • The Canvas abstract class defines an abstract
    method paint(Graphics g).
  • Each concrete Canvas subclass must implement the
    paint() method to specify how to draw itself on
    the screen.
  • When a Canvas object is displayed, the paint()
    method is automatically invoked. The Graphics
    object is passed in by the Java runtime.
    Developers do not invoke the paint() method
    directly.
  • When the screen needs updating, the application
    calls repaint(), which schedules the runtime to
    call the paint() method.

32
  • Graphics
  • The Graphics class provides methods to do the
    actual drawing on a Canvas.
  • It is usually passed into the Canvas.paint()
    method.
  • Lines
  • Outline of geometric objects such as arcs and
    rectangles
  • Filled geometric objects
  • Text strings
  • Images
  • public void drawChar(char c, int x, int y, int
    anchor)
  • public void drawSubstring(String str, int offset,
    int len, int x, int y, int anchor) public void
    drawImage(Image img, int x, int y, int
    anchor)public void drawLine(int x1, int y1, int
    x2, int y2)
  • public void drawArc(int x, int y, int width, int
    height, int startAngle, int arcAngle)

33
Key-event model
  • When the user presses a key, the MIDP runtime
    calls the Canvas.keyPressed() method and passes
    the key code.
  • By default, the keyPressed() method does nothing.
    It just ignores the event.
  • The Canvas subclass overrides it to respond to
    the event.
  • public void keyPressed(int keyCode)
  • public void keyReleased(int keyCode)
  • public void keyRepeated(int keyCode)

34
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com