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

📄 display.java

📁 用于移动设备上的java虚拟机源代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * call to <code>setCurrent()</code>     * is unlikely to return the value passed to <code>setCurrent()</code>.     *     * <p> Calls to <code>setCurrent()</code> are not queued.  A     * delayed request made by a     * <code>setCurrent()</code> call may be superseded by a subsequent call to     * <code>setCurrent()</code>.  For example, if screen     * <code>S1</code> is current, then </p>     *     * <TABLE BORDER="2">     * <TR>     * <TD ROWSPAN="1" COLSPAN="1">     *    <pre><code>     *     d.setCurrent(S2);     *     d.setCurrent(S3);     </code></pre>     * </TD>     * </TR>     * </TABLE>     *     * <p> may eventually result in <code>S3</code> being made     * current, bypassing <code>S2</code>     * entirely. </p>     *     * <p> When a <code>MIDlet</code> application is first started,     * there is no current     * <code>Displayable</code> object.  It is the responsibility of     * the application to     * ensure that a <code>Displayable</code> is visible and can     * interact with the user at     * all times.  Therefore, the application should always call     * <code>setCurrent()</code>     * as part of its initialization. </p>     *     * <p> The application may pass <code>null</code> as the argument to     * <code>setCurrent()</code>.  This does not have the effect of     * setting the current     * <code>Displayable</code> to <code>null</code>; instead, the     * current <code>Displayable</code>     * remains unchanged.  However, the application management software may     * interpret this call as a request from the application that it is     * requesting to be placed into the background.  Similarly, if the     * application is in the background, passing a non-null     * reference to <code>setCurrent()</code> may be interpreted by     * the application     * management software as a request that the application is     * requesting to be     * brought to the foreground.  The request should be considered to be made     * even if the current <code>Displayable</code> is passed to the     * <code>setCurrent()</code>.  For     * example, the code </p>     * <TABLE BORDER="2">     * <TR>     * <TD ROWSPAN="1" COLSPAN="1">     *    <pre><code>     *   d.setCurrent(d.getCurrent());    </code></pre>     * </TD>     * </TR>     * </TABLE>     * <p> generally will have no effect other than requesting that the     * application be brought to the foreground.  These are only requests,     * and there is no requirement that the application management     * software comply with these requests in a timely fashion if at all. </p>     *     * <p> If the <code>Displayable</code> passed to     * <code>setCurrent()</code> is an {@link Alert     * Alert}, the previously current <code>Displayable</code>, if     * any, is restored after     * the <code>Alert</code> has been dismissed.  If there is a     * current <code>Displayable</code>, the     * effect is as if <code>setCurrent(Alert, getCurrent())</code>     * had been called.  Note     * that this will result in an exception being thrown if the current     * <code>Displayable</code> is already an alert.  If there is no     * current <code>Displayable</code>     * (which may occur at startup time) the implementation's previous state     * will be restored after the <code>Alert</code> has been     * dismissed.  The automatic     * restoration of the previous <code>Displayable</code> or the     * previous state occurs     * only when the <code>Alert's</code> default listener is present     * on the <code>Alert</code> when it     * is dismissed.  See <a href="Alert.html#commands">Alert Commands and     * Listeners</a> for details.</p>     *     * <p>To specify the     * <code>Displayable</code> to be shown after an     * <code>Alert</code> is dismissed, the application     * should use the {@link #setCurrent(Alert,Displayable) setCurrent(Alert,     * Displayable)} method.  If the application calls     * <code>setCurrent()</code> while an     * <code>Alert</code> is current, the <code>Alert</code> is     * removed from the display and any timer     * it may have set is cancelled. </p>     *     * <p> If the application calls <code>setCurrent()</code> while a     * system screen is     * active, the effect may be delayed until after the system screen is     * dismissed.  The implementation may choose to interpret     * <code>setCurrent()</code> in     * such a situation as a request to cancel the effect of the system     * screen, regardless of whether <code>setCurrent()</code> has     * been delayed. </p>     *     * @param nextDisplayable the <code>Displayable</code> requested     * to be made current;     * <code>null</code> is allowed     * @see #getCurrent     */    public void setCurrent(Displayable nextDisplayable) {        synchronized (LCDUILock) {            if (nextDisplayable instanceof Alert) {                /*                 * This implicitly goes back to the current screen.                 *                 * If there is a pending screen change, we take that                 * into account also.  This probably acts according to                 * the principle of least astonishment.  Also, it                 * has the effect of preventing an implicit call of                 * setCurrent(Alert, Alert) because nextScreen is                 * never an alert.                 *                 * REMIND: This is subject to spec interpretation;                 * the handling of setCurrent(Alert) is a weak area.                 */                // NOTE: Removed the copy of the Alert                ((Alert)nextDisplayable).setReturnScreen(current);            }            setCurrentImpl(nextDisplayable);        } // synchronized    }    /**     * Requests that this <code>Alert</code> be made current, and that     * <code>nextDisplayable</code> be     * made current     * after the <code>Alert</code> is dismissed.  This call returns     * immediately regardless     * of the <code>Alert's</code> timeout value or whether it is a     * modal alert.  The     * <code>nextDisplayable</code> must not be an <code>Alert</code>,     * and it must not be <code>null</code>.     *     * <p>The automatic advance to <code>nextDisplayable</code> occurs only      * when the <code>Alert's</code> default listener is present on     * the <code>Alert</code> when it     * is dismissed.  See <a href="Alert.html#commands">Alert Commands and     * Listeners</a> for details.</p>     *      * <p> In other respects, this method behaves identically to     * {@link #setCurrent(Displayable) setCurrent(Displayable)}. </p>     *     * @param alert the alert to be shown     * @param nextDisplayable the <code>Displayable</code> to be     * shown after this alert is  dismissed     *      * @throws NullPointerException if alert or     * <code>nextDisplayable</code> is <code>null</code>     * @throws IllegalArgumentException if <code>nextDisplayable</code>     * is an <code>Alert</code>     * @see Alert     * @see #getCurrent     */    public void setCurrent(Alert alert, Displayable nextDisplayable) {        if ((alert == null) || (nextDisplayable == null)) {            throw new NullPointerException();        }        if (nextDisplayable instanceof Alert) {            throw new IllegalArgumentException();        }        synchronized (LCDUILock) {            alert.setReturnScreen(nextDisplayable);            setCurrentImpl(alert);        }    }    /**     * Requests that the <code>Displayable</code> that contains this     * <code>Item</code> be made current,     * scrolls the <code>Displayable</code> so that this     * <code>Item</code> is visible, and possibly     * assigns the focus to this <code>Item</code>.  The containing     * <code>Displayable</code> is first     * made current as if {@link #setCurrent(Displayable)     * setCurrent(Displayable)} had been called.  When the containing     * <code>Displayable</code> becomes current, or if it is already     * current, it is     * scrolled if necessary so that the requested <code>Item</code>     * is made visible.     * Then, if the implementation supports the notion of input focus, and if     * the <code>Item</code> accepts the input focus, the input focus     * is assigned to the     * <code>Item</code>.     *     * <p>This method always returns immediately, without waiting for the     * switching of the <code>Displayable</code>, the scrolling, and     * the assignment of     * input focus to take place.</p>     *     * <p>It is an error for the <code>Item</code> not to be contained     * within a container.     * It is also an error if the <code>Item</code> is contained     * within an <code>Alert</code>.</p>     *     * @param item the item that should be made visible     * @throws IllegalStateException if the item is not owned by a container     * @throws IllegalStateException if the item is owned by an      * <code>Alert</code>     * @throws NullPointerException if <code>item</code> is <code>null</code>     * @since MIDP 2.0     */    public void setCurrentItem(Item item) {        synchronized (LCDUILock) {            Screen nextDisplayable = item.getOwner();            if (nextDisplayable instanceof Form) {                ((Form)nextDisplayable).setCurrentItem(item);            }            if (nextDisplayable == null) {                throw new IllegalStateException();            }            setCurrentImpl(nextDisplayable);        } // synchronized    }    /**     * Causes the <code>Runnable</code> object <code>r</code> to have     * its <code>run()</code> method     * called later, serialized with the event stream, soon after completion of     * the repaint cycle.  As noted in the     * <a href="./package-summary.html#events">Event Handling</a>     * section of the package summary,     * the methods that deliver event notifications to the application     * are all called serially. The call to <code>r.run()</code> will     * be serialized along with     * the event calls into the application. The <code>run()</code>     * method will be called exactly once for each call to     * <code>callSerially()</code>. Calls to <code>run()</code> will     * occur in the order in which they were requested by calls to     * <code>callSerially()</code>.     *     * <p> If the current <code>Displayable</code> is a <code>Canvas</code>     * that has a repaint pending at the time of a call to     * <code>callSerially()</code>, the <code>paint()</code> method of the     * <code>Canvas</code> will be called and     * will return, and a buffer switch will occur (if double buffering is in     * effect), before the <code>run()</code> method of the     * <code>Runnable</code> is called.     * If the current <code>Displayable</code> contains one or more     * <code>CustomItems</code> that have repaints pending at the time     * of a call to <code>callSerially()</code>, the <code>paint()</code>     * methods of the <code>CustomItems</code> will be called and will     * return before the <code>run()</code> method of the     * <code>Runnable</code> is called.     * Calls to the     * <code>run()</code> method will occur in a timely fashion, but     * they are not guaranteed     * to occur immediately after the repaint cycle finishes, or even before     * the next event is delivered. </p>     *     * <p> The <code>callSerially()</code> method may be called from     * any thread. The call to     * the <code>run()</code> method will occur independently of the     * call to <code>callSerially()</code>.     * In particular, <code>callSerially()</code> will <em>never</em>     * block waiting     * for <code>r.run()</code>     * to return. </p>     *     * <p> As with other callbacks, the call to <code>r.run()</code>     * must return quickly. If     * it is necessary to perform a long-running operation, it may be initiated     * from within the <code>run()</code> method. The operation itself     * should be performed     * within another thread, allowing <code>run()</code> to return. </p>     *     * <p> The <code>callSerially()</code> facility may be used by     * applications to run an     * animation that is properly synchronized with the repaint cycle. A     * typical application will set up a frame to be displayed and then call     * <code>repaint()</code>.  The application must then wait until     * the frame is actually     * displayed, after which the setup for the next frame may occur.  The call     * to <code>run()</code> notifies the application that the     * previous frame has finished     * painting.  The example below shows <code>callSerially()</code>     * being used for this     * purpose. </p>     * <TABLE BORDER="2">     * <TR>     * <TD ROWSPAN="1" COLSPAN="1">     *    <pre><code>     *     class Animation extends Canvas     *         implements Runnable {     *     *     // paint the current frame     *     void paint(Graphics g) { ... }     *     *        Display display; // the display for the application     *     *        void paint(Graphics g) { ... } // paint the current frame     *     *        void startAnimation() {     *            // set up initial frame     *            repaint();     *            display.callSerially(this);     *        }     *     *        // called after previous repaint is finished     *        void run() {     *            if ( &#47;* there are more frames *&#47; ) {     *                // set up the next frame     *                repaint();     *                display.callSerially(this);     *            }     *        }     *     }    </code></pre>     * </TD>     * </TR>     * </TABLE>     * @param r instance of interface <code>Runnable</code> to be called     */    public void callSerially(Runnable r) {        if (r == null) {            throw new NullPointerException();        }        synchronized (LCDUILock) {            currentQueue.addElement(r);            eventHandler.scheduleCallSerially();        }    }    /**     * Requests a flashing effect for the device's backlight.  The flashing     * effect is intended to be used to attract the user's attention or as a     * special effect for games.  Examples of flashing are cycling the     * backlight on and off or from dim to bright repeatedly.     * The return value indicates if the flashing of the backlight     * can be controlled by the application.     *     * <p>The flashing effect occurs for the requested duration, or it is     * switched off if the requested duration is zero.  This method returns     * immediately; that is, it must not block the caller while the flashing     * effect is running.</p>     *     * <p>Calls to this method are honored only if the     * <code>Display</code> is in the

⌨️ 快捷键说明

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