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

📄 list.java

📁 用于移动设备上的java虚拟机源代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     *    <pre><code>     *     // Command c is the select command on List list         *     list.setSelectCommand(null);         *     list.removeCommand(c);     </code></pre>     * </TD>     * </TR>     * </TABLE>     * @param cmd the command to be removed     *     * @since MIDP 2.0     */    public void removeCommand(Command cmd) {        synchronized (Display.LCDUILock) {            super.removeCommandImpl(cmd);            if (cmd == selectCommand) {                selectCommand = null;            }        } // synchronized    }    /**     * Sets the <code>Command</code> to be used for an     * <code>IMPLICIT</code> <code>List</code> selection     * action.     * By default, an implicit selection of a List will result in the     * predefined <code>List.SELECT_COMMAND</code> being used. This     * behavior may be     * overridden by calling the <code>List.setSelectCommand()</code>     * method with an     * appropriate parameter value.  If a <code>null</code> reference     * is passed, this     * indicates that no &quot;select&quot; action is appropriate for     * the contents     * of this <code>List</code>.     *     * <p> If a reference to a command object is passed, and     * it is not the special command <code>List.SELECT_COMMAND</code>, and     * it is not currently present on this <code>List</code> object,     * the command object is added to this <code>List</code> as if     * <code>addCommand(command)</code> had been called     * prior to the command being made the select command.  This     * indicates that this command     * is to be invoked when the user performs the &quot;select&quot;     * on an element of     * this <code>List</code>. </p>     *     * <p> The select command should have a command type of     * <code>ITEM</code> to indicate     * that it operates on the currently selected object.  It is not an error     * if the command is of some other type.     * (<code>List.SELECT_COMMAND</code> has a type     * of <code>SCREEN</code> for historical purposes.)  For purposes     * of presentation and     * placement within its user interface, the implementation is allowed to     * treat the select command as if it were of type <code>ITEM</code>. </p>     *     * <p> If the select command is later removed from the <code>List</code>     * with <code>removeCommand()</code>, the <code>List</code> is set to have     * no select command as if <code>List.setSelectCommand(null)</code> had     * been called.</p>     *     * <p> The default behavior can be reestablished explicitly by calling     * <code>setSelectCommand()</code> with an argument of     * <code>List.SELECT_COMMAND</code>.</p>     *     * <p> This method has no effect if the type of the     * <code>List</code> is not <code>IMPLICIT</code>. </p>     *     * @param command the command to be used for an <code>IMPLICIT</code> list     * selection action, or <code>null</code> if there is none     *     * @since MIDP 2.0     */    public void setSelectCommand(Command command) {        // If we're not an IMPLICIT List, ignore this method        // call entirely        if (cg.getType() != Choice.IMPLICIT) {            return;        }        // Here we're just resetting the default behavior        // of this implicit List        if (command == List.SELECT_COMMAND) {            selectCommand = command;            return;        }        // Here we're deciding there is no appropriate default        // command for a selection        if (command == null) {            selectCommand = null;            return;        }        // SYNC NOTE: We grab the lock here because we need to determine        // if the command is in the Displayables command set AND we need        // to protect ourselves from the Command being removed from the        // set just after we've done the check. #See how we override the        // removeCommand() method in this class        synchronized (Display.LCDUILock) {            // We ensure that the provided Command has been added            // to this List.	    addCommandImpl(command);            selectCommand = command;        }    }    /**     * Sets the application's preferred policy for fitting     * <code>Choice</code> element     * contents to the available screen space. The set policy applies for all     * elements of the <code>Choice</code> object.  Valid values are     * {@link #TEXT_WRAP_DEFAULT}, {@link #TEXT_WRAP_ON},     * and {@link #TEXT_WRAP_OFF}. Fit policy is a hint, and the     * implementation may disregard the application's preferred policy.     *     * @param fitPolicy preferred content fit policy for choice elements     * @throws IllegalArgumentException if <code>fitPolicy</code> is invalid     * @see #getFitPolicy     * @since MIDP 2.0     */    public void setFitPolicy(int fitPolicy) {        cg.setFitPolicy(fitPolicy);    }    /**     * Gets the application's preferred policy for fitting     * <code>Choice</code> element     * contents to the available screen space.  The value returned is the      * policy that had been set by the application, even if that value had      * been disregarded by the implementation.     *     * @return one of {@link #TEXT_WRAP_DEFAULT}, {@link #TEXT_WRAP_ON}, or     * {@link #TEXT_WRAP_OFF}     * @see #setFitPolicy     * @since MIDP 2.0     */    public int getFitPolicy() {        return cg.getFitPolicy();    }    /**     * Sets the application's preferred font for     * rendering the specified element of this <code>Choice</code>.     * An element's font is a hint, and the implementation may disregard     * the application's preferred font.     *     * <p> The <code>elementNum</code> parameter must be within the range     * <code>[0..size()-1]</code>, inclusive.</p>     *     * <p> The <code>font</code> parameter must be a valid <code>Font</code>     * object or <code>null</code>. If the <code>font</code> parameter is     * <code>null</code>, the implementation must use its default font     * to render the element.</p>     *     * @param elementNum the index of the element, starting from zero     * @param font the preferred font to use to render the element     * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid     * @see #getFont     * @since MIDP 2.0     */    public void setFont(int elementNum, Font font) {	    cg.setFont(elementNum, font);    }    /**     * Gets the application's preferred font for     * rendering the specified element of this <code>Choice</code>. The     * value returned is the font that had been set by the application,     * even if that value had been disregarded by the implementation.     * If no font had been set by the application, or if the application     * explicitly set the font to <code>null</code>, the value is the default     * font chosen by the implementation.     *     * <p> The <code>elementNum</code> parameter must be within the range     * <code>[0..size()-1]</code>, inclusive.</p>     *     * @param elementNum the index of the element, starting from zero     * @return the preferred font to use to render the element     * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid     * @see #setFont(int elementNum, Font font)     * @since MIDP 2.0     */    public Font getFont(int elementNum) {        return cg.getFont(elementNum);    }    // package private methods //    /**     * Notify this Displayable it is being shown on the given Display     *     * @param d the Display showing this Displayable     */    void callShowNotify(Display d) {        super.callShowNotify(d);        form.callShowNotify(d);    }    /**     * Notify this Displayable it is being hidden on the given Display     *     * @param d the Display hiding this Displayable     */    void callHideNotify(Display d) {        super.callHideNotify(d);        form.callHideNotify(d);    }    /**     * Handle a key pressed event     *     * @param keyCode The key that was pressed     */    void callKeyPressed(int keyCode) {        form.callKeyPressed(keyCode);        if (keyCode == Display.KEYCODE_SELECT) {	    // don't invoke the select command if there are	    // no elements in the List	    if (cg.size() == 0) {		return;	    }            CommandListener cl = null;            synchronized (Display.LCDUILock) {                cl = listener;            }            if (cl != null) {                try {                    // SYNC NOTE: We lock on calloutLock around any calls                    // into application code                    synchronized (Display.calloutLock) {                        cl.commandAction(selectCommand, this);                    }                } catch (Throwable thr) {                    Display.handleThrowable(thr);                }            }        }    }    /**     * Display calls this method on it's current Displayable.     * SYNC NOTE: The caller of this method handles synchronization.     *     * @param g the graphics context to paint into.     * @param target the target Object of this repaint     */    void callPaint(Graphics g, Object target) {        form.callPaint(g, target);    }    /**     * Called by the event thread to invalidate the contents     * of this List     *     * @param src the Item which may have caused the invalidation     */    void callInvalidate(Item src) {        form.callInvalidate(src);    }    /**     * Called by the event thread to notify an ItemStateChangeListener     * that an item has changed     *     * @param src the Item which has changed     */    void callItemStateChanged(Item src) {        form.callItemStateChanged(src);    }}

⌨️ 快捷键说明

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