⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listimage.java

📁 j2me下的1套UI框架.包含j2me开发中会应用的各种低级组件
💻 JAVA
字号:
package com.jmobilecore.ui.core;

import javax.microedition.lcdui.Image;

/**
 * Provides an image for display as part of <code>List</code> component.  <code>ListImage</code> is focusable.
 *
 * @author Greg Gridin
 */
public class ListImage extends ImageComponent implements ListComponent {

    /**
     * The textual description of the image.
     * @see #getText
     * @see #setText
     */
    protected String text;

    /**
     * A key stoke that ia associated with a list item.
     * To remove you have to assign to it <code>PlatformCanvas.KEY_UNDEFINED</code> value
     * @see #getShortcut
     * @see #setShortcut
     */
    protected int shortcut = PlatformCanvas.KEY_UNDEFINED;

    /**
     * This field indicates the command has been issued by a  particular list item.
     * By default the <code>actionCommand</code> is the image of the <code>ListImage</code>,
     * unless it has been explicitly set to a different value.
     * @see #getAction
     * @see #setAction
     */
    protected Object actionCommand = null;

    /**
     * Create a list image
     *
     * @param image    the label for this list image.
     */
    public ListImage(Image image) {
        this(image, PlatformCanvas.KEY_UNDEFINED, image);
    }

    /**
     * Create a list image with an associated keyboard shortcut.
     *
     * @param image    the label for this list image.
     * @param shortcut key code associated witha list image.
     */
    public ListImage(Image image, int shortcut) {
        this(image, shortcut, image);
    }

    /**
     * Create a list image with an associated keyboard shortcut and custom action.
     *
     * @param image    the label for this list image.
     * @param shortcut key code associated witha list image.
     * @param action   custom action for the <code>ListImage</code>
     */
    public ListImage(Image image, int shortcut, Object action) {
        super(image, Label.LEFT);
        setShortcut(shortcut);
        setAction(action);
        focusable = true;
    }

    /**
     * Get textual representation of the <code>ListImage</code> component
     * This method is required by <code>ListComponent</code> interface
     *
     * @return the textual representation of the component
     */
    public String getText() {
        return text;
    }

    /**
     * Sets the key code shortcut for this <code>ListImage</code> component
     * This method is required by <code>ListComponent</code> interface
     *
     * @param text the new textual representation of the component
     */
    public void setText(String text) {
        this.text = text;
    }

    /**
     * Get the key code shortcut for this <code>ListImage</code>
     * This method is required by <code>ListComponent</code> interface
     *
     * @return the keycode shortcut
     */
    public int getShortcut() {
        return shortcut;
    }

    /**
     * Sets the key code shortcut for this <code>ListImage</code>
     * This method is required by <code>ListComponent</code> interface
     *
     * @param shortcut the keycode - new shortcut value
     */
    public void setShortcut(int shortcut) {
        this.shortcut = shortcut;
    }

    /**
     * Get the object representing the <code>ListImage</code>'s action
     * This method is required by <code>ListComponent</code> interface
     *
     * @return the object associated with this <code>ListLabel</code>
     */
    public Object getAction() {
        return actionCommand;
    }

    /**
     * Sets the object as <code>ListLabel</code>'s action
     * This method is required by <code>ListComponent</code> interface
     *
     * @param action the object - new action value
     */
    public void setAction(Object action) {
        this.actionCommand = action;
    }

    /**
     * Default destructor. Helps VM to perform garbage collection
     */
    public void destructor() {
        actionCommand = null;
        super.destructor();
    }

} // class ListImage

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -