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

📄 stringitem.java

📁 有关j2me的很好的例子可以研究一下
💻 JAVA
字号:
/* * @(#)StringItem.java	1.37 01/08/09 * Copyright (c) 1999-2001 Sun Microsystems, Inc. All Rights Reserved. * * This software is the confidential and proprietary information of Sun * Microsystems, Inc. ("Confidential Information").  You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Sun. * * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING * THIS SOFTWARE OR ITS DERIVATIVES. */package javax.microedition.lcdui;/** * An item that can contain a string. A StringItem is display-only; the user * cannot edit the contents. Both the label and the textual content of a * StringItem may be modified by the application. The visual representation * of the label may differ from that of the textual contents. */public class StringItem extends Item {    /** The text of this StringItem */    private String text;    /**     * Creates a new StringItem object with the given label and textual content.     * Either label or text may be present or null.     *     * @param label the Item label     * @param text the text contents     */    public StringItem(String label, String text) {        super(label);        // SYNC NOTE: Its clear we're only initializing instance variables        // so ok to leave unlocked        this.text = text;        layouts = new Layout[1];    }    /**     * Gets the text contents of the StringItem, or null if the StringItem is     * empty.     * @return a string with the content of the item     *     * @see #setText     */    public String getText() {        // SYNC NOTE: return of atomic value, no locking necessary        return text;    }    /**     * Sets the text contents of the StringItem. If text is null, the StringItem     * is set to be empty.     * @param text the new content     *     * @see #getText     */    public void setText(String text) {        synchronized (Display.LCDUILock) {            this.text = text;            handleContentChanged();        }    }    /**     * Sets the label of the Item. If label is null, specifies that this     * item has no label.     * @param label the label string     */    public void setLabel(String label) {        synchronized (Display.LCDUILock) {            super.setLabel(label);            handleContentChanged();        }    }    // package private    /**     * StringItems and ImageItems are grouped together.     *     * @param item  to be checked against     * @return true if this Item and passed in item are part of the      *         same group, otherwise false is returned     */    boolean isGrouped(Item item) {        if (item != null && item.isGroupable()) {            return item.layouts[0] == layouts[0];        }        return false;    }    /**     * Determines if that item can be grouped with other items in a     * common layout.     * @return true if this item can be grouped with others;      *         false - otherwise     */    boolean isGroupable() {        return true;    }    /**     * Determine if this StringItem takes focus     *     * @return boolean True, if this StringItem can take the focus     */    boolean takesFocus() {        return false;    }    /**     * Get the height of this StringItem     *     * @return int The height (in pixels) of this StringItem     */    int getHeight() {        if (layouts[0] == null) {            return 0;        }        return layouts[0].getHeight();    }    /**     * Set the width for this StringItem     *     * @param width The allowable width     * @return int The height required to display this StringItem given     *              the allowable width     */    int setWidth(int width) {        if (layouts[0] == null) {            return 0;        }        return layouts[0].setWidth(width);    }    /**     * Paint this StringItem     *     * @param g The Graphics object to paint to     */    void paint(Graphics g) {        if (layouts[0] != null) {            layouts[0].paint(g, true, false);        }    }    // private    /**     * Handle a content change     */    private void handleContentChanged() {        if (!initLayoutDone() || layouts[0] == null) {            return;        }        contentChanged(0, 0,            ((TaGLayout)layouts[0]).itemContentChanged(this));    }}

⌨️ 快捷键说明

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