Appendix A. Low-Level GUI Classes

Game Classes

The following listing contains a brief description of commonly used J2ME GUI classes. All the following classes are in the javax.microedition.lcdui package.

  • Alert—. Shows data to the user and waits for a certain period of time.

  • AlertType—. Designates the nature of an Alert.

  • Canvas—. Handles low-level events and draws to the display.

  • ChoiceGroup—. A group of selectable elements.

  • Command—. A user action.

  • DateField—. An editable component for presenting date and time information.

  • Display—. Represents the manager of the display and input devices for the device.

  • Displayable—. A superclass of all Screens that can be put on the display.

  • Font—. Text fonts and font metrics.

  • Form—. A Screen that contains common user interface items.

  • Gauge—. A bar graph display.

  • Graphics—. Allows for drawing and 2D geometric rendering.

  • Image—. Holds graphical image data.

  • ImageItem—. Adds an Image to a Form or to an Alert.

  • Item—. A superclass for components that can be added to a Form and Alert.

  • List—. A Screen containing a list of choices.

  • Screen—. An abstract superclass defining the display at any given time.

  • StringItem—. Holds a string.

  • TextBox—. Allows the user to enter and edit text.

  • TextField—. An editable text component.

  • Ticker—. A piece of text that scrolls continuously across the display.

The associated interfaces are

  • Choice—. Components that can be selected from a predefined number of choices.

  • CommandListener—. Receives high-level events.

  • ItemStateListener—. Receives events that indicate changes in the internal state of the interactive items within a Form screen.

The hierarchy is as follows:

java.lang.Object
        javax.microedition.lcdui.AlertType
        javax.microedition.lcdui.Command
        javax.microedition.lcdui.Display
        javax.microedition.lcdui.Displayable
            javax.microedition.lcdui.Canvas
            javax.microedition.lcdui.Screen
                javax.microedition.lcdui.Alert
                javax.microedition.lcdui.Form
                javax.microedition.lcdui.List (implements
                javax.microedition.lcdui.Choice)
                javax.microedition.lcdui.TextBox
            javax.microedition.lcdui.Font
            javax.microedition.lcdui.Graphics
            javax.microedition.lcdui.Image
            javax.microedition.lcdui.Item
            javax.microedition.lcdui.ChoiceGroup (implements
            javax.microedition.lcdui.Choice)
        javax.microedition.lcdui.DateField
        javax.microedition.lcdui.Gauge
        javax.microedition.lcdui.ImageItem
        javax.microedition.lcdui.StringItem
        javax.microedition.lcdui.TextField
    javax.microedition.lcdui.Ticker

Complete method listings for each of these classes are provided throughout the rest of this appendix.

javax.microedition.lcdui.AlertType

  • AlertType()

  • boolean playSound(Display display)

javax.microedition.lcdui.Command

  • Command(String label, int commandType,int priority)

  • int getCommandType()

  • String getLabel()

  • int getPriority()

  • String to String()

javax.microedition.lcdui.Display

  • void callSerially(Runnable obj)

  • Displayable getCurrent()

  • static Display getDisplay(MIDlet c)

  • boolean isColor()

  • int numColors()

  • void setCurrent(Alert alert, Displayable next)

  • void setCurrent(Displayable next)

javax.microedition.lcdui.Displayable

  • void addCommand(Command cmd)

  • boolean isShown()

  • void removeCommand(Command cmd)

  • void setCommandListener(CommandListener l)

javax.microedition.lcdui.Canvas

  • Canvas()

  • int getGameAction(int keyCode)

  • int getHeight()

  • int getKeyCode(int gameAction)

  • String getKeyName(int keyCode)

  • int getWidth()

  • boolean hasPointerEvents()

  • boolean hasPointerMotionEvents()

  • boolean hasRepeatEvents()

  • protected void hideNotify()

  • boolean isDoubleBuffered()

  • protected void keyPressed(int keyCode)

  • protected void keyReleased(int keyCode)

  • protected void keyRepeated(int keyCode)

  • protected abstract void paint(Graphics g)

  • protected void pointerDragged(int x, int y)

  • protected void pointerPressed(int x, int y)

  • protected void pointerReleased(int x, int y)

  • void repaint()

  • void repaint(int x, int y, int width, int height)

  • void serviceRepaints()

  • protected void showNotify()

javax.microedition.lcdui.Screen

  • Ticker getTicker()

  • String getTitle()

  • void setTicker(Ticker newTicker)

  • void setTitle(String newTitle)

javax.microedition.lcdui.Alert

  • Alert(String title)

  • Alert(String title,String alertText,Image alertImage, AlertType alertType)

  • void addCommand(Command cmd)

  • int getDefaultTimeout()

  • Image getImage()

  • String getString()

  • int getTimeout()

  • AlertType getType()

  • void setCommandListener(CommandListener l)

  • void setImage(Image img)

  • void setString(String str)

  • void setTimeout(int time)

  • void setType(AlertType type)

javax.microedition.lcdui.Form

  • Form(String title)

  • Form(String title, Item[] items)

  • int append(Image image)

  • int append(Item item)

  • int append(String str)

  • void delete(int index)

  • Item get(int index)

  • void insert(int index, Item item)

  • void set(int index, Item item)

  • void setItemStateListener(ItemStateListener iListener)

  • int size()

javax.microedition.lcdui.List

  • List(String title, int listType)

  • List(String title, int listType, String[] stringElements, Image[] int append(String stringElement, Image imageElement)

  • void delete(int index)

  • Image getImage(int index)

  • int getSelectedFlags(boolean[] selectedArray_return)

  • int getSelectedIndex()

  • String getString(int index)

  • void insert(int index, String stringElement, Image imageElement)

  • boolean isSelected(int index)

  • void set(int index, String stringElement, Image imageElement)

  • void setSelectedFlags(boolean[] selectedArray)

  • void setSelectedIndex(int index, boolean selected)

  • int size()

javax.microedition.lcdui.TextBox

  • TextBox(String title, String text, int maxSize, int constraints)

  • void delete(int offset, int length)

  • int getCaretPosition()

  • int getChars(char[] data)

  • int getConstraints()

  • int getMaxSize()

  • String getString()

  • void insert(char[] data, int offset, int length, int position)

  • void insert(String src, int position)

  • void setChars(char[] data, int offset, int length)

  • void setConstraints(int constraints)

  • int setMaxSize(int maxSize)

  • void setString(String text)

  • int size()

javax.microedition.lcdui.Font

  • int charsWidth(char[] ch, int offset, int length)

  • int charWidth(char ch)

  • int getBaselinePosition()

  • static Font getDefaultFont()

  • int getFace()

  • static Font getFont(int face, int style, int size)

  • int getHeight()

  • int getSize()

  • int getStyle()

  • boolean isBold()

  • boolean isItalic()

  • boolean isPlain()

  • boolean isUnderlined()

  • int stringWidth(String str)

  • int substringWidth(String str, int offset, int len)

javax.microedition.lcdui.Graphics

  • void clipRect(int x, int y, int width, int height)

  • void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)

  • void drawChar(char character, int x, int y, int anchor)

  • void drawChars(char[] data, int offset, int length, int x, int y, int anchor)

  • void drawImage(Image img, int x, int y, int anchor)

  • void drawLine(int x1, int y1, int x2, int y2)

  • 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 drawString(String str, int x, int y, int anchor)

  • void drawSubstring(String str, int offset, int len, int x, int y, int anchor)

  • void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)

  • void fillRect(int x, int y, int width, int height)

  • void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)

  • int getBlueComponent()

  • int getClipHeight()

  • int getClipWidth()

  • int getClipX()

  • int getClipY()

  • int getColor()

  • Font getFont()

  • int getGrayScale()

  • int getGreenComponent()

  • int getRedComponent()

  • int getStrokeStyle()

  • int getTranslateX()

  • int getTranslateY()

  • void setClip(int x, int y, int width, int height)

  • void setColor(int RGB)

  • void setColor(int red, int green, int blue)

  • void setFont(Font font)

  • void setGrayScale(int value)

  • void setStrokeStyle(int style)

  • void translate(int x, int y)

javax.microedition.lcdui.Image

  • static Image createImage(byte[] imageData, int imageOffset, int imageLength)

  • static Image createImage(Image image)

  • static Image createImage(int width, int height)

  • static Image createImage(String name)

  • static Image createImage(byte[] imageData, int offset, int imageLength)

  • Graphics getGraphics()

  • int getHeight()

  • int getWidth()

  • boolean isMutable()

javax.microedition.lcdui.Item

  • String getLabel()

  • void setLabel(String label)

javax.microedition.lcdui.ChoiceGroup

  • ChoiceGroup(String label, int choiceType)

  • ChoiceGroup(String label, int choiceType, String[] stringElements, Image[] imageElements)

  • int append(String stringElement, Image imageElement)

  • void delete(int index)

  • Image getImage(int index)

  • int getSelectedFlags(boolean[] selectedArray_return)

  • int getSelectedIndex()

  • String getString(int index)

  • void insert(int index, String stringElement, Image imageElement)

  • boolean isSelected(int index)

  • void set(int index, String stringElement, Image imageElement)

  • void setSelectedFlags(boolean[] selectedArray)

  • void setSelectedIndex(int index, boolean selected)

  • int size()

javax.microedition.lcdui.DateField

  • DateField(String label, int mode)

  • DateField(String label, int mode, TimeZone timeZone)

  • Date getDate()

  • int getInputMode()

  • void setDate(Date date)

  • void setInputMode(int mode)

javax.microedition.lcdui.Gauge

  • Gauge(String label, boolean interactive, int maxValue, int initialValue)

  • int getMaxValue()

  • int getValue()

  • boolean isInteractive()

  • void setMaxValue(int maxValue)

  • void setValue(int value)

javax.microedition.lcdui.ImageItem

  • ImageItem(String label, Image img, int layout, String altText)

  • String getAltText()

  • Image getImage()

  • int getLayout()

  • void setAltText(String text)

  • void setImage(Image img)

  • void setLayout(int layout)

javax.microedition.lcdui.StringItem

  • StringItem(String label, String text)

  • String getText()

  • void setText(String text)

javax.microedition.lcdui.TextField

  • TextField(String label, String text, int maxSize, int constraints)

  • void delete(int offset, int length)

  • int getCaretPosition()

  • int getChars(char[] data)

  • int getConstraints()

  • int getMaxSize()

  • String getString()

  • void insert(char[] data, int offset, int length, int position)

  • void insert(String src, int position)

  • void setChars(char[] data, int offset, int length)

  • void setConstraints(int constraints)

  • int setMaxSize(int maxSize)

  • void setString(String text)

  • int size()

javax.microedition.lcdui.Ticker

  • Ticker(String str)

  • String getString()

  • void setString(String str)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.214.27