item.java

来自「This is a resource based on j2me embedde」· Java 代码 · 共 1,133 行 · 第 1/3 页

JAVA
1,133
字号
    public final static int LAYOUT_RIGHT = 2;    /**     * A layout directive indicating that this <code>Item</code> should have a     * horizontally centered layout.     *     * <P>Value <code>3</code> is assigned to <code>LAYOUT_CENTER</code>.</P>     */    public final static int LAYOUT_CENTER = 3;    /**     * A layout directive indicating that this <code>Item</code> should have a     * top-aligned layout.     *     * <P>Value <code>0x10</code> is assigned to <code>LAYOUT_TOP</code>.</P>     */    public final static int LAYOUT_TOP = 0x10;    /**     * A layout directive indicating that this <code>Item</code> should have a     * bottom-aligned layout.     *     * <P>Value <code>0x20</code> is assigned to <code>LAYOUT_BOTTOM</code>.</P>     */    public final static int LAYOUT_BOTTOM = 0x20;    /**     * A layout directive indicating that this <code>Item</code> should have a     * vertically centered layout.     *     * <P>Value <code>0x30</code> is assigned to      * <code>LAYOUT_VCENTER</code>.</P>     */    public final static int LAYOUT_VCENTER = 0x30;    /**     * A layout directive indicating that this <code>Item</code>      * should be placed at the beginning of a new line or row.     *     * <P>Value <code>0x100</code> is assigned to      * <code>LAYOUT_NEWLINE_BEFORE</code>.</P>     */    public final static int LAYOUT_NEWLINE_BEFORE = 0x100;    /**     * A layout directive indicating that this <code>Item</code>     * should the last on its line or row, and that the next     * <code>Item</code> (if any) in the container     * should be placed on a new line or row.     *     * <P>Value <code>0x200</code> is assigned to      * <code>LAYOUT_NEWLINE_AFTER</code>.</P>     */    public final static int LAYOUT_NEWLINE_AFTER = 0x200;    /**     * A layout directive indicating that this <code>Item's</code>     * width may be reduced to its minimum width.     *     *<P>Value <code>0x400</code> is assigned to <code>LAYOUT_SHRINK</code></P>     */    public final static int LAYOUT_SHRINK = 0x400;    /**     * A layout directive indicating that this <code>Item's</code>      * width may be increased to fill available space.     *     *<P>Value <code>0x800</code> is assigned to <code>LAYOUT_EXPAND</code>.</P>     */    public final static int LAYOUT_EXPAND = 0x800;    /**     * A layout directive indicating that this <code>Item's</code>     * height may be reduced to its minimum height.     *     * <P>Value <code>0x1000</code> is assigned to     * <code>LAYOUT_VSHRINK</code>.</P>     */    public final static int LAYOUT_VSHRINK = 0x1000;    /**     * A layout directive indicating that this <code>Item's</code>      * height may be increased to fill available space.     *     * <P>Value <code>0x2000</code> is assigned to      * <code>LAYOUT_VEXPAND</code>.</P>     */    public final static int LAYOUT_VEXPAND = 0x2000;    /**     * A layout directive indicating that new MIDP layout     * rules are in effect for this <code>Item</code>.  If this     * bit is clear, indicates that MIDP 1.0 layout behavior     * applies to this <code>Item</code>.     *     * <P>Value <code>0x4000</code> is assigned to     * <code>LAYOUT_2</code>.</P>     *      */    public static final int LAYOUT_2 = 0x4000;    /**     * An appearance mode value indicating that the <code>Item</code> is to have     * a normal appearance.     *     * <P>Value <code>0</code> is assigned to <code>PLAIN</code>.</P>     */    public final static int PLAIN = 0;    /**     * An appearance mode value indicating that the <code>Item</code>     * is to appear as a hyperlink.     * <P>Value <code>1</code> is assigned to <code>HYPERLINK</code>.</P>     */    public final static int HYPERLINK = 1;    /**     * An appearance mode value indicating that the <code>Item</code>     * is to appear as a button.     * <P>Value <code>2</code> is assigned to <code>BUTTON</code>.</P>     */    public final static int BUTTON = 2;// ************************************************************//  Static initializer, constructor// ************************************************************    /**     * Creates a new item with a given label.     *     * @param label the label string; null is allowed     */    Item(String label) {        // SYNC NOTE: probably safe, but since subclasses can't lock        // around their call to super(), we'll lock it here        synchronized (Display.LCDUILock) {            this.label = label;        }    }// ************************************************************//  public methods// ************************************************************    /**     * Sets the label of the <code>Item</code>. If <code>label</code>     * is <code>null</code>, specifies that this item has no label.     *      * <p>It is illegal to call this method if this <code>Item</code>     * is contained within  an <code>Alert</code>.</p>     *      * @param label the label string     * @throws IllegalStateException if this <code>Item</code> is contained      * within an <code>Alert</code>     * @see #getLabel     */    public void setLabel(String label) {        synchronized (Display.LCDUILock) {            if (label != this.label && 	        (label == null || !label.equals(this.label))) {                this.label = label;                itemLF.lSetLabel(label);            }        }    }        /**     * Gets the label of this <code>Item</code> object.     * @return the label string     * @see #setLabel     */    public String getLabel() {        // SYNC NOTE: return of atomic value, no locking necessary        return label;    }    /**     * Gets the layout directives used for placing the item.     * @return a combination of layout directive values     * @see #setLayout     */    public int getLayout() {        // SYNC NOTE: return of atomic value, no locking necessary        return layout;    }    /**     * Sets the layout directives for this item.     *     * <p>It is illegal to call this method if this <code>Item</code>      * is contained within an <code>Alert</code>.</p>     *      * @param layout a combination of layout directive values for this item     * @throws IllegalArgumentException if the value of layout is not a     * bit-wise OR combination of layout directives     * @throws IllegalStateException if this <code>Item</code> is     * contained within an <code>Alert</code>     * @see #getLayout     */    public void setLayout(int layout) {        synchronized (Display.LCDUILock) {            int oldLayout = this.layout;            setLayoutImpl(layout);            if (oldLayout != this.layout) {                itemLF.lSetLayout(layout);            }        }    }    /**     * Adds a context sensitive <code>Command</code> to the item.     * The semantic type of     * <code>Command</code> should be <code>ITEM</code>. The implementation     * will present the command     * only when the item is active, for example, highlighted.     * <p>     * If the added command is already in the item (tested by comparing the     * object references), the method has no effect. If the item is     * actually visible on the display, and this call affects the set of     * visible commands, the implementation should update the display as soon     * as it is feasible to do so.     *     * <p>It is illegal to call this method if this <code>Item</code>     * is contained within an <code>Alert</code>.</p>     *     * @param cmd the command to be added     * @throws IllegalStateException if this <code>Item</code> is contained     * within an <code>Alert</code>     * @throws NullPointerException if cmd is <code>null</code>     */    public void addCommand(Command cmd) {        synchronized (Display.LCDUILock) {            addCommandImpl(cmd);        }    }    /**     * Removes the context sensitive command from item. If the command is not     * in the <code>Item</code> (tested by comparing the object references),     * the method has     * no effect. If the <code>Item</code> is actually visible on the display,      * and this  call     * affects the set of visible commands, the implementation should update     * the display as soon as it is feasible to do so.     *     *     * If the command to be removed happens to be the default command,     * the command is removed and the default command on this Item is     * set to <code>null</code>.     *     * The following code:     * <CODE> <pre>     *     // Command c is the default command on Item item     *     item.removeCommand(c);     * </pre> </CODE>     * is equivalent to the following code:     * <CODE> <pre>     *     // Command c is the default command on Item item     *     item.setDefaultCommand(null);     *     item.removeCommand(c);     * </pre> </CODE>     *     *     * @param cmd the command to be removed     */    public void removeCommand(Command cmd) {        synchronized (Display.LCDUILock) {            removeCommandImpl(cmd);        }    }    /**     * Sets a listener for <code>Commands</code> to this <code>Item</code>,     * replacing any previous     * <code>ItemCommandListener</code>. A <code>null</code> reference     * is allowed and has the effect of     * removing any existing listener.     *     * <p>It is illegal to call this method if this <code>Item</code>     * is contained within an <code>Alert</code>.</p>     *     * @param l the new listener, or <code>null</code>.     * @throws IllegalStateException if this <code>Item</code> is contained     * within an <code>Alert</code>     */    public void setItemCommandListener(ItemCommandListener l) {        synchronized (Display.LCDUILock) {            commandListener = l;        }    }    /**     * Gets the preferred width of this <code>Item</code>.       * If the application has locked     * the width to a specific value, this method returns that value.     * Otherwise, the return value is computed based on the      * <code>Item's</code> contents,     * possibly with respect to the <code>Item's</code> preferred height      * if it is locked.     * See <a href="#sizes">Item Sizes</a> for a complete discussion.     *     * @return the preferred width of the Item     * @see #getPreferredHeight     * @see #setPreferredSize     */    public int getPreferredWidth() {	synchronized (Display.LCDUILock) {	    if (lockedWidth != -1) {		return lockedWidth;	    } else { 		return itemLF.lGetPreferredWidth(lockedHeight);	    }	}    }    /**     * Gets the preferred height of this <code>Item</code>.       * If the application has locked     * the height to a specific value, this method returns that value.     * Otherwise, the return value is computed based on the      * <code>Item's</code> contents,     * possibly with respect to the <code>Item's</code> preferred      * width if it is locked.     * See <a href="#sizes">Item Sizes</a> for a complete discussion.     *     * @return the preferred height of the <code>Item</code>     * @see #getPreferredWidth     * @see #setPreferredSize     */    public int getPreferredHeight() {	synchronized (Display.LCDUILock) {	    if (lockedHeight != -1) {		return lockedHeight;	    } else {		return itemLF.lGetPreferredHeight(lockedWidth);	    }	}    }    /**     * Sets the preferred width and height for this <code>Item</code>.     * Values for width and height less than <code>-1</code> are illegal.     * If the width is between zero and the minimum width, inclusive,     * the minimum width is used instead.     * If the height is between zero and the minimum height, inclusive,     * the minimum height is used instead.     *     * <p>Supplying a width or height value greater than the minimum width or      * height <em>locks</em> that dimension to the supplied     * value.  The implementation may silently enforce a maximum dimension for      * an <code>Item</code> based on factors such as the screen size.      * Supplying a value of     * <code>-1</code> for the width or height unlocks that dimension.     * See <a href="#sizes">Item Sizes</a> for a complete discussion.</p>     *      * <p>It is illegal to call this method if this <code>Item</code>      * is contained within  an <code>Alert</code>.</p>     *      * @param width the value to which the width should be locked, or     * <code>-1</code> to unlock     * @param height the value to which the height should be locked, or      * <code>-1</code> to unlock     * @throws IllegalArgumentException if width or height is less than      * <code>-1</code>     * @throws IllegalStateException if this <code>Item</code> is contained     * within an <code>Alert</code>     * @see #getPreferredHeight     * @see #getPreferredWidth     */    public void setPreferredSize(int width, int height) {        if (width < -1 || height < -1) {            throw new IllegalArgumentException();        }        synchronized (Display.LCDUILock) {            if (owner != null && owner instanceof Alert) {

⌨️ 快捷键说明

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