1 / 60

PROGRAMMING WITH J2ME

PROGRAMMING WITH J2ME. Presenter: Tran Duc Minh Email: minhtd@gmail.com. CONTENT. Introduction to J2ME and MIDP Setting environment for J2ME Standard GUI Low level GUI. 1. Introduction to J2ME and MIDP. Configuration Connected Device Configuration (CDC)

dezso
Download Presentation

PROGRAMMING WITH J2ME

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PROGRAMMING WITH J2ME Presenter: Tran Duc Minh Email: minhtd@gmail.com

  2. CONTENT Introduction to J2ME and MIDP Setting environment for J2ME Standard GUI Low level GUI

  3. 1. Introduction to J2ME and MIDP Configuration Connected Device Configuration (CDC) Connected, Limited Device Configuration (CLDC)

  4. 1. Introduction to J2ME and MIDP Profiles MIDP MIDlets The Application Manager

  5. Configuration A J2ME configuration defines a Java platform for a range of devices Each configuration encompasses the features available in the Java language as well as the core libraries

  6. Connected Device Configuration (CDC) 512 kilobytes (minimum) memory for running Java programs 256 kilobytes (minimum) for run time memory allocation Network connectivity, possibly persistent, and high-bandwidth

  7. Connected, Limited Device Configuration (CLDC) 128 KB of memory for running Java programs 32 KB of memory for run time memory allocation A limited user interface Runs on battery power Wireless network connection, low bandwidth

  8. Profiles A J2ME profile is an extension of a configuration It defines the libraries available to a developer writing applications for a specific device type

  9. MIDP The MIDP extends the CLDC MIDP defines APIs for UI components, input and event handling, persistent storage, and networking and timers… MIDP offers a high-level and low-level API

  10. MIDlets A MIDlet is a Java application that is built on top of the CLDC and MIDP A MIDlet suite consists of one or more MIDlets packaged together as a JAR

  11. The Application Manager The software on the mobile device that is responsible for installing, running, and removing MIDlets

  12. 2. Setting Environments Setting on Eclipse IDE Setting on Ktoolbar (See the attach demo)

  13. 3. Standard GUI Display, Displayable and Screen objects Form and Item List, Textbox, Alert, Ticker

  14. Display, Displayable and Screen objects A MIDlet has one instance of a Display object. This object is used to obtain information about the current display

  15. Display, Displayable and Screen objects A Displayable object is a component that is visible on a device. For example: Forms, TextBoxes, ChoiceGroups, etc. A Screen object is not something that is visible on the device Screen is subclassed by high-level components

  16. Display, Displayable and Screen objects

  17. Form and Item DateField Gauge StringItem TextField ChoiceGroup Image and ImageItem

  18. DateField The DateField component provides a means to visually manipulate a Date object Construtor: DateField(String label, int mode) DateField(String label, int mode, TimeZone timeZone)

  19. DateField The DateField has mode: DateField.DATE_TIME DateField.DATE_TIME DateField.DATE

  20. Gauge A Gauge component displays a progress-meter style interface There are two types of Gauge: interactive and non-interactive Construtor: Gauge(String label, boolean interactive, int maxValue, int initialValue)

  21. Gauge

  22. StringItem A StringItem component is used to display a label or string Construtor: StringItem(String label, String text)

  23. StringItem

  24. TextField A Textfield is analogous to any typical text entry field Constructor: TextField(String label, String text, int maxSize, int constraints)

  25. TextField TextField has following modes: ANY EMAILADDR NUMERIC PHONENUMBER URL PASSWORD

  26. TextField

  27. ChoiceGroup ChoiceGroup components allow a user to select from a predefined list of entries There are two ChoiceGroup mode: multi-selection(checkbox) and exclusive-selection(radio button) Constructor: (See the j2me api reference)

  28. ChoiceGroup

  29. Image and ImageItem Image is used to create an image object and holds information MIDP offers two types of images: immutable and mutable

  30. Image and ImageItem

  31. 4.Low level GUI Canvas Graphics

  32. Canvas The coordinate system Keycodes Game actions

  33. Canvas The Canvas class provides the backdrop for creating a custom (or low-level) user interface Canvas provides a large number of methods to handle events and draw images and text onto the device display

  34. The coordinate system

  35. The coordinate system Following methods determine the width and height of the canvas : int getWidth() int getHeight () The software on an MIDP device will always return the maximum drawing area available for a given device

  36. The coordinate system The Canvas class method paint() lets you draw shapes, display images, write text… protected void paint(Graphics g) { // Set background color to white g.setColor(255, 255, 255); // Fill the entire canvas g.fillRect(0, 0, getWidth(), getHeight()); }

  37. The coordinate system class TestCanvas extends Canvas implements CommandListener { private Command cmdExit; ... display = Display.getDisplay(this); cmdExit = new Command("Exit", Command.EXIT, 1); addCommand(cmdExit); setCommandListener(this); ... protected void paint(Graphics g) { // Draw onto the canvas ... } public void commandAction(Command c, Displayable d) { if (c == cmdExit) ... } }

  38. Keycodes In addition to soft-keys for processing commands, a Canvas object has access to 12 keycodes The codes that are guaranteed to be available on any MIDP device

  39. Keycodes KEY_NUM0, KEY_NUM1 KEY_NUM2, KEY_NUM3 KEY_NUM4, KEY_NUM5 KEY_NUM6, KEY_NUM7 KEY_NUM8, KEY_NUM9 KEY_STAR, KEY_POUND

  40. Keycodes void keyPressed(int keyCode) void keyReleased(int keyCode) void keyRepeated(int keyCode) boolean hasRepeatEvents() String getKeyName(int keyCode)

  41. Keycodes void keyPressed(int keyCode) void keyReleased(int keyCode) void keyRepeated(int keyCode) boolean hasRepeatEvents() String getKeyName(int keyCode)

  42. Graphics Color support Stroke style Drawing shapes Working with fonts Anchor points Drawing text Drawing images Additional Graphics methods

  43. Color support boolean isColor() int numColors() void setColor(int RGB) void setColor(int red, int green, int blue) int getColor() int int getRedComponent() int getGreenComponent() int getBlueComponent()

  44. Stroke style int getStrokeStyle() void setStrokeStyle(int style) The two stroke style constants are: DOTTED SOLID

  45. Draw Arc void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)

  46. Draw Arc

  47. Draw Rectangle void drawRect(int x, int y, int width, int height) void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) void fillRect(int x, int y, int width, int height) void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)

  48. Draw Rectangle

  49. Font Font getFont(int face, int style, int size) Font getFont(int fontSpecifier) Font getDefaultFont() Example: Font font = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD | Font.STYLE_ITALIC, Font.SIZE_MEDIUM); Font font = Font.getFont(Font.FONT_INPUT_TEXT);

More Related