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

📄 displayable.java

📁 有关j2me的很好的例子可以研究一下
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }    /**     * Get the current horizontal scroll position     *     * @return int The value of the current horizontal scroll position     *             on a scale of 0-100     */    int getHorizontalScrollPosition() {        return hScrollPosition;    }    /**     * Get the current horizontal scroll proportion     *     * @return int The value of the current horizontal scroll proportion     *             on a scale of 0-100     */    int getHorizontalScrollProportion() {        return hScrollProportion;    }    /**     * The vertical scroll position     */    private int vScrollPosition     = 0;    /**     * The vertical scroll proportion     */    private int vScrollProportion   = 100;    /**     * Set the vertical scroll position and proportion     *     * @param scrollPosition The vertical scroll position to set on a     *                       scale of 0-100     * @param scrollProportion The vertical scroll proportion to set on     *                         a scale of 0-100. For example, if the viewport     *                         is 25 pixels high and the Displayable is 100     *                         pixels high, then the scroll proportion would     *                         be 25, since only 25% of the Displayable can     *                         be viewed at any one time. This proportion     *                         value can be used by implementations which     *                         render scrollbars to indicate scrollability     *                         to the user.     */    void setVerticalScroll(int scrollPosition, int scrollProportion) {        this.vScrollPosition = scrollPosition;        this.vScrollProportion = scrollProportion;        synchronized (Display.LCDUILock) {            if ((currentDisplay != null) && currentDisplay.isShown(this)) {                currentDisplay.setVerticalScroll(scrollPosition,                                                 scrollProportion);            }        }    }    /**     * Get the current vertical scroll position     *     * @return int The vertical scroll position on a scale of 0-100     */    int getVerticalScrollPosition() {        return vScrollPosition;    }    /**     * Get the current vertical scroll proportion     *     * @return ing The vertical scroll proportion on a scale of 0-100     */    int getVerticalScrollProportion() {        return vScrollProportion;    }    // ************** private implementation ***********************    /** The current Display object */    Display currentDisplay;    /** An array of Commands added to this Displayable */    Command commands[];    /** The number of Commands added to this Displayable */    int numCommands;    /** The CommandListener for Commands added to this Displayable */    CommandListener listener;    /**     * Notify this Displayable it is being shown on the screen     *     * @param d The Display showing this Displayable     */    void showNotify(Display d) {        synchronized (Display.LCDUILock) {            showNotifyImpl(d);        }        // SYNC NOTE: Since showNotify() may result in a call into        // application code, we first release LCDUILock and then        // acquire calloutLock before making the call        synchronized (Display.calloutLock) {            // Protect from any unexpected application exceptions            try {                showNotify();            } catch (Throwable thr) {                Display.handleThrowable(thr);            }        }    }    /**     * Notify this Displayable it is being hidden     *     * @param d The Display which is no longer showing this Displayable     */    void hideNotify(Display d) {        synchronized (Display.LCDUILock) {            hideNotifyImpl(d);        }        // SYNC NOTE: Since hideNotify() may result in a call into        // application code, we first release LCDUILock and then        // acquire calloutLock before making the call        synchronized (Display.calloutLock) {            // Protect from any unexpected application exceptions            try {                hideNotify();            } catch (Throwable thr) {                Display.handleThrowable(thr);            }        }    }    // This is the only implementation of showNotify in the LCDUI package    /** Notify this Displayable it is being shown on the screen */    void showNotify() { }    // This is the only implementation of hideNotify in the LCDUI package    /** Notify this Displayable it is being hidden */    void hideNotify() { }    /**     * Notify this Displayable it is being shown on the screen     *     * @param d The Display showing this Displayable     */    void showNotifyImpl(Display d) {        currentDisplay = d;    }    /**     * Notify this Displayable it is being hidden     *     * @param d The Display which is no longer showing this Displayable     */    void hideNotifyImpl(Display d) {        currentDisplay = null;    }    /**     * Get the set of Commands that have been added to this Displayable     *     * @return Command[] The array of Commands added to this Displayable     */    Command[] getCommands() {        return commands;    }    /**     * Get the number of commands that have been added to this Displayable     *     * @return int The number of commands that have been added to this     *              Displayable     */    int getCommandCount() {        return numCommands;    }    /**     * Get the CommandListener for this Displayable     *     * @return CommandListener The CommandListener listening to Commands on     *                          this Displayable     */    CommandListener getCommandListener() {        return listener;    }    /**     * Add a Command to this Displayable     *     * @param cmd The Command to add to this Displayable     */    void addCommandImpl(Command cmd) {        for (int i = 0; i < numCommands; ++i) {            if (commands[i] == cmd) {                return;            }        }        if ((commands == null) || (numCommands == commands.length)) {            Command[] newCommands = new Command[numCommands + 4];            if (commands != null) {                System.arraycopy(commands, 0, newCommands, 0, numCommands);            }            commands = newCommands;        }        commands[numCommands] = cmd;        ++numCommands;        if ((currentDisplay != null) && currentDisplay.isShown(this)) {            currentDisplay.updateCommandSet();        }    }    /**     * Remove a Command from this Displayable     *     * @param cmd The Command to remove from this Displayable     */    void removeCommandImpl(Command cmd) {        for (int i = 0; i < numCommands; ++i) {            if (commands[i] == cmd) {                commands[i] = commands[--numCommands];                commands[numCommands] = null;                if ((currentDisplay != null) &&                        currentDisplay.isShown(this)) {                    currentDisplay.updateCommandSet();                }                break;            }        }    }}

⌨️ 快捷键说明

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