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

📄 component.java

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    public Cursor getCursor() {        Cursor cursor = this.cursor;        if (cursor != null) {            return cursor;        }        Container parent = this.parent;        if (parent != null) {            return parent.getCursor();        } else {            return Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);        }    }    /**     * Returns whether the cursor has been explicitly set for this Component.     * If this method returns <code>false</code>, this Component is inheriting     * its cursor from an ancestor.     *     * @return <code>true</code> if the cursor has been explicitly set for this     *         Component; <code>false</code> otherwise.     * @since 1.4     */    public boolean isCursorSet() {        return (cursor != null);    }    /**     * Paints this component.  This method is called when the contents     * of the component should be painted in response to the component     * first being shown or damage needing repair.  The clip rectangle     * in the Graphics parameter will be set to the area which needs     * to be painted.     * For performance reasons, Components with zero width or height     * aren't considered to need painting when they are first shown,     * and also aren't considered to need repair.     * @param g The graphics context to use for painting.     * @see       java.awt.Component#update     * @since     JDK1.0     */    public void paint(Graphics g) {}    /**     * Updates this component.     * <p>     * The AWT calls the <code>update</code> method in response to a     * call to <code>repaint</code. The appearance of the     * component on the screen has not changed since the last call to     * <code>update</code> or <code>paint</code>. You can assume that     * the background is not cleared.     * <p>     * The <code>update</code>method of <code>Component</code>     * does the following:     * <p>     * <blockquote><ul>     * <li>Clears this component by filling it     *      with the background color.     * <li>Sets the color of the graphics context to be     *     the foreground color of this component.     * <li>Calls this component's <code>paint</code>     *     method to completely redraw this component.     * </ul></blockquote>     * <p>     * The origin of the graphics context, its     * (<code>0</code>,&nbsp;<code>0</code>) coordinate point, is the     * top-left corner of this component. The clipping region of the     * graphics context is the bounding rectangle of this component.     * @param g the specified context to use for updating.     * @see       java.awt.Component#paint     * @see       java.awt.Component#repaint()     * @since     JDK1.0     */    public void update(Graphics g) {        paint(g);    }    /**     * Paints this component and all of its subcomponents.     * <p>     * The origin of the graphics context, its     * (<code>0</code>,&nbsp;<code>0</code>) coordinate point, is the     * top-left corner of this component. The clipping region of the     * graphics context is the bounding rectangle of this component.     * @param     g   the graphics context to use for painting.     * @see       java.awt.Component#paint     * @since     JDK1.0     */    public void paintAll(Graphics g) {        if (isShowing()) {            validate();            paint(g);        }    }    /**     * Repaints this component.     * <p>     * This method causes a call to this component's <code>update</code>     * method as soon as possible.     * @see       java.awt.Component#update(java.awt.Graphics)     * @since     JDK1.0     */    public void repaint() {        repaint(0, 0, 0, width, height);    }    /**     * Repaints the component. This will result in a     * call to <code>update</code> within <em>tm</em> milliseconds.     * @param tm maximum time in milliseconds before update     * @see #paint     * @see java.awt.Component#update(java.awt.Graphics)     * @since JDK1.0     */    public void repaint(long tm) {        repaint(tm, 0, 0, width, height);    }    /**     * Repaints the specified rectangle of this component.     * <p>     * This method causes a call to this component's <code>update</code>     * method as soon as possible.     * @param     x   the <i>x</i> coordinate.     * @param     y   the <i>y</i> coordinate.     * @param     width   the width.     * @param     height  the height.     * @see       java.awt.Component#update(java.awt.Graphics)     * @since     JDK1.0     */    public void repaint(int x, int y, int width, int height) {        repaint(0, x, y, width, height);    }    /**     * Repaints the specified rectangle of this component within     * <code>tm</code> milliseconds.     * <p>     * This method causes a call to this component's     * <code>update</code> method.     * @param     tm   maximum time in milliseconds before update.     * @param     x    the <i>x</i> coordinate.     * @param     y    the <i>y</i> coordinate.     * @param     width    the width.     * @param     height   the height.     * @see       java.awt.Component#update(java.awt.Graphics)     * @since     JDK1.0     */    public void repaint(long tm, final int x, final int y, final int width, final int height) {        if (width <= 0 || height <= 0)            return;        Rectangle componentArea = new Rectangle(0, 0, this.width, this.height);        Rectangle repaintArea = new Rectangle(x, y, width, height);        if (!componentArea.intersects(repaintArea))            return;        final Rectangle clippedRepaintArea = componentArea.intersection(repaintArea);        if (displayable) {            Component c = this;            /* Find outer most heavyweight component to send an PaintEvent.UPDATE event to.             Beacuse Window, Panel and Canvas are traditionally heavyweight components repaints             should cause update to be called on these components. Calling repaint on a lightweight             component should not call update on that component but its heavyweight ancestor. */            while (c != null) {                if (c instanceof Window && c.visible) {                    //Thread.dumpStack();                    if (tm == 0)                        Toolkit.getEventQueue().postEvent(new PaintEvent (c, PaintEvent.UPDATE, clippedRepaintArea));                        //SunToolkit.postEvent(c.appContext, new PaintEvent (c, PaintEvent.UPDATE, clippedRepaintArea));                    else {                        final int x1 = x, y1 = y;                        final Component c1 = c;                        // 6312976, lazy initialization                        if (TIMER == null) {                           TIMER = new Timer();                        }                        TIMER.schedule(new TimerTask() {                                public void run() {                                    Toolkit.getEventQueue().postEvent(new PaintEvent (c1, PaintEvent.UPDATE, clippedRepaintArea));                                    //SunToolkit.postEvent(c1.appContext, new PaintEvent (c1, PaintEvent.UPDATE, clippedRepaintArea));                                }                            }, tm);                    }                    return;                }                clippedRepaintArea.x += c.x;                clippedRepaintArea.y += c.y;                c = c.parent;            }        }    }    /**     * Prints this component. Applications should override this method     * for components that must do special processing before being     * printed or should be printed differently than they are painted.     * <p>     * The default implementation of this method calls the     * <code>paint</code> method.     * <p>     * The origin of the graphics context, its     * (<code>0</code>,&nbsp;<code>0</code>) coordinate point, is the     * top-left corner of this component. The clipping region of the     * graphics context is the bounding rectangle of this component.     * @param     g   the graphics context to use for printing.     * @see       java.awt.Component#paint(java.awt.Graphics)     * @since     JDK1.0     */    public void print(Graphics g) {        paint(g);    }    /**     * Prints this component and all of its subcomponents.     * <p>     * The origin of the graphics context, its     * (<code>0</code>,&nbsp;<code>0</code>) coordinate point, is the     * top-left corner of this component. The clipping region of the     * graphics context is the bounding rectangle of this component.     * @param     g   the graphics context to use for printing.     * @see       java.awt.Component#print(java.awt.Graphics)     * @since     JDK1.0     */    public void printAll(Graphics g) {        if (isShowing()) {            validate();            Graphics cg = g.create(0, 0, width, height);            cg.setFont(getFont());            try {                print(g);            } finally {                cg.dispose();            }        }    }    /**     * Repaints the component when the image has changed.     * This <code>imageUpdate</code> method of an <code>ImageObserver</code>     * is called when more information about an     * image which had been previously requested using an asynchronous     * routine such as the <code>drawImage</code> method of     * <code>Graphics</code> becomes available.     * See the definition of <code>imageUpdate</code> for     * more information on this method and its arguments.     * <p>     * The <code>imageUpdate</code> method of <code>Component</code>     * incrementally draws an image on the component as more of the bits     * of the image are available.     * <p>     * If the system property <code>awt.image.incrementalDraw</code>     * is missing or has the value <code>true</code>, the image is     * incrementally drawn, If the system property has any other value,     * then the image is not drawn until it has been completely loaded.     * <p>     * Also, if incremental drawing is in effect, the value of the     * system property <code>awt.image.redrawrate</code> is interpreted     * as an integer to give the maximum redraw rate, in milliseconds. If     * the system property is missing or cannot be interpreted as an     * integer, the redraw rate is once every 100ms.     * <p>     * The interpretation of the <code>x</code>, <code>y</code>,     * <code>width</code>, and <code>height</code> arguments depends on     * the value of the <code>infoflags</code> argument.     *     * @param     img   the image being observed.     * @param     infoflags   see <code>imageUpdate</code> for more information.     * @param     x   the <i>x</i> coordinate.     * @param     y   the <i>y</i> coordinate.     * @param     w   the width.     * @param     h   the height.     * @return    <code>false</code> if the infoflags indicate that the     *            image is completely loaded; <code>true</code> otherwise.     *     * @see     java.awt.image.ImageObserver     * @see     java.awt.Graphics#drawImage(java.awt.Image, int, int, java.awt.Color, java.awt.image.ImageObserver)     * @see     java.awt.Graphics#drawImage(java.awt.Image, int, int, java.awt.image.ImageObserver)     * @see     java.awt.Graphics#drawImage(java.awt.Image, int, int, int, int, java.awt.Color, java.awt.image.ImageObserver)     * @see     java.awt.Graphics#drawImage(java.awt.Image, int, int, int, int, java.awt.image.ImageObserver)     * @see     java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)     * @since   JDK1.0     */    public boolean imageUpdate(Image img, int flags,        int x, int y, int w, int h) {        int rate = -1;        if ((flags & (FRAMEBITS | ALLBITS)) != 0) {            rate = 0;        } else if ((flags & SOMEBITS) != 0) {            if (isInc) {                try {                    rate = incRate;                    if (rate < 0)                        rate = 0;                } catch (Exception e) {                    rate = 100;                }            }        }        if (rate >= 0) {            repaint(rate, 0, 0, width, height);        }        return (flags & (ALLBITS | ABORT)) == 0;    }    /**     * Creates an image from the specified image producer.     * @param     producer  the image producer     * @return    the image produced.     * @since     JDK1.0     */    public Image createImage(ImageProducer producer) {        return getToolkit().createImage(producer);    }    /**     * Creates an off-screen drawable image     *     to be used for double buffering.     * @param     width the specified width.     * @param     height the specified height.     * @return    an off-screen drawable image,     *            which can be used for double buffering.     * @since     JDK1.0     */    public Image createImage(int width, int height) {        return (displayable) ? getToolkit().createImage(this, width, height) : null;    }    /**     * Creates a volatile off-screen drawable image     *     to be used for double buffering.     * @param     width the specified width.     * @param     height the specified height.     * @return    an off-screen drawable image, which can be used for double     *    buffering.  The return value may be <code>null</code> if the     *    component is not displayable.  This will always happen if     *    <code>GraphicsEnvironment.isHeadless()</code> returns     *    <code>true</code>.     * @see java.awt.image.VolatileImage     * @see #isDisplayable     * @see GraphicsEnvironment#isHeadless     * @since     1.4     */    public VolatileImage createVolatileImage(int width, int height) {        //6209548        GraphicsConfiguration gc = getGraphicsConfiguration();        if ( displayable && gc != null ) {		    return gc.createCompatibleVolatileImage(width, height);        }        return null;        //6209548    }    /**     * Creates a volatile off-screen drawable image, with the given capabilities.     * The contents of this image may be lost at any time due     * to operating system issues, so the image must be managed     * via the <code>VolatileImage</code> interface.     * @param width the specified width.     * @param height the specified height.     * @param caps the image capabilities     * @exception AWTException if an image with the specified capabilities cannot     * be created     * @return a VolatileImage object, which can be used     * to manage surface contents loss and capabilities.     * @see java.awt.image.VolatileImage     * @since 1.4     */    public VolatileImage createVolatileImag

⌨️ 快捷键说明

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