📄 canvas.html
字号:
<DT><B>Parameters:</B><DD><CODE>keyCode</CODE> - the key code of the key that was repeated<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/Canvas.html#hasRepeatEvents()"><CODE>hasRepeatEvents()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="keyReleased(int)"><!-- --></A><H3>
keyReleased</H3>
<PRE>
protected void <B>keyReleased</B>(int keyCode)</PRE>
<DL>
<DD>Called when a key is released. <P> The <code>getGameAction()</code> method can be called to determine what game action, if any, is mapped to the key. Class <code>Canvas</code> has an empty implementation of this method, and the subclass has to redefine it if it wants to listen this method. </P><DD><DL>
<DT><B>Parameters:</B><DD><CODE>keyCode</CODE> - the key code of the key that was released</DL>
</DD>
</DL>
<HR>
<A NAME="pointerPressed(int, int)"><!-- --></A><H3>
pointerPressed</H3>
<PRE>
protected void <B>pointerPressed</B>(int x, int y)</PRE>
<DL>
<DD>Called when the pointer is pressed. <P> The <A HREF="../../../javax/microedition/lcdui/Canvas.html#hasPointerEvents()"><CODE>hasPointerEvents()</CODE></A> method may be called to determine if the device supports pointer events. Class <code>Canvas</code> has an empty implementation of this method, and the subclass has to redefine it if it wants to listen this method. </P><DD><DL>
<DT><B>Parameters:</B><DD><CODE>x</CODE> - the horizontal location where the pointer was pressed (relative to the <code>Canvas</code>)<DD><CODE>y</CODE> - the vertical location where the pointer was pressed (relative to the <code>Canvas</code>)</DL>
</DD>
</DL>
<HR>
<A NAME="pointerReleased(int, int)"><!-- --></A><H3>
pointerReleased</H3>
<PRE>
protected void <B>pointerReleased</B>(int x, int y)</PRE>
<DL>
<DD>Called when the pointer is released. <P> The <A HREF="../../../javax/microedition/lcdui/Canvas.html#hasPointerEvents()"><CODE>hasPointerEvents()</CODE></A> method may be called to determine if the device supports pointer events. Class <code>Canvas</code> has an empty implementation of this method, and the subclass has to redefine it if it wants to listen this method. </P><DD><DL>
<DT><B>Parameters:</B><DD><CODE>x</CODE> - the horizontal location where the pointer was released (relative to the <code>Canvas</code>)<DD><CODE>y</CODE> - the vertical location where the pointer was released (relative to the <code>Canvas</code>)</DL>
</DD>
</DL>
<HR>
<A NAME="pointerDragged(int, int)"><!-- --></A><H3>
pointerDragged</H3>
<PRE>
protected void <B>pointerDragged</B>(int x, int y)</PRE>
<DL>
<DD>Called when the pointer is dragged. <P> The <A HREF="../../../javax/microedition/lcdui/Canvas.html#hasPointerMotionEvents()"><CODE>hasPointerMotionEvents()</CODE></A> method may be called to determine if the device supports pointer events. Class <code>Canvas</code> has an empty implementation of this method, and the subclass has to redefine it if it wants to listen this method. </P><DD><DL>
<DT><B>Parameters:</B><DD><CODE>x</CODE> - the horizontal location where the pointer was dragged (relative to the <code>Canvas</code>)<DD><CODE>y</CODE> - the vertical location where the pointer was dragged (relative to the <code>Canvas</code>)</DL>
</DD>
</DL>
<HR>
<A NAME="repaint(int, int, int, int)"><!-- --></A><H3>
repaint</H3>
<PRE>
public final void <B>repaint</B>(int x, int y, int width, int height)</PRE>
<DL>
<DD>Requests a repaint for the specified region of the <code>Canvas</code>. Calling this method may result in subsequent call to <code>paint()</code>, where the passed <code>Graphics</code> object's clip region will include at least the specified region. <p> If the canvas is not visible, or if width and height are zero or less, or if the rectangle does not specify a visible region of the display, this call has no effect. </p> <p> The call to <code>paint()</code> occurs asynchronously of the call to <code>repaint()</code>. That is, <code>repaint()</code> will not block waiting for <code>paint()</code> to finish. The <code>paint()</code> method will either be called after the caller of <code>repaint(</code>) returns to the implementation (if the caller is a callback) or on another thread entirely. </p> <p> To synchronize with its <code>paint()</code> routine, applications can use either <A HREF="../../../javax/microedition/lcdui/Display.html#callSerially(java.lang.Runnable)"><CODE>Display.callSerially()</CODE></A> or <A HREF="../../../javax/microedition/lcdui/Canvas.html#serviceRepaints()"><CODE>serviceRepaints()</CODE></A>, or they can code explicit synchronization into their <code>paint()</code> routine. </p> <p> The origin of the coordinate system is above and to the left of the pixel in the upper left corner of the displayable area of the <code>Canvas</code>. The X-coordinate is positive right and the Y-coordinate is positive downwards. </p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>x</CODE> - the x coordinate of the rectangle to be repainted<DD><CODE>y</CODE> - the y coordinate of the rectangle to be repainted<DD><CODE>width</CODE> - the width of the rectangle to be repainted<DD><CODE>height</CODE> - the height of the rectangle to be repainted<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/Display.html#callSerially(java.lang.Runnable)"><CODE>Display.callSerially(Runnable)</CODE></A>,
<A HREF="../../../javax/microedition/lcdui/Canvas.html#serviceRepaints()"><CODE>serviceRepaints()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="repaint()"><!-- --></A><H3>
repaint</H3>
<PRE>
public final void <B>repaint</B>()</PRE>
<DL>
<DD>Requests a repaint for the entire <code>Canvas</code>. The effect is identical to <p> <code> repaint(0, 0, getWidth(), getHeight()); </code></DL>
<HR>
<A NAME="serviceRepaints()"><!-- --></A><H3>
serviceRepaints</H3>
<PRE>
public final void <B>serviceRepaints</B>()</PRE>
<DL>
<DD>Forces any pending repaint requests to be serviced immediately. This method blocks until the pending requests have been serviced. If there are no pending repaints, or if this canvas is not visible on the display, this call does nothing and returns immediately. <p><strong>Warning:</strong> This method blocks until the call to the application's <code>paint()</code> method returns. The application has no control over which thread calls <code>paint()</code>; it may vary from implementation to implementation. If the caller of <code>serviceRepaints()</code> holds a lock that the <code>paint()</code> method acquires, this may result in deadlock. Therefore, callers of <code>serviceRepaints()</code> <em>must not</em> hold any locks that might be acquired within the <code>paint()</code> method. The <A HREF="../../../javax/microedition/lcdui/Display.html#callSerially(java.lang.Runnable)"><CODE>Display.callSerially()</CODE></A> method provides a facility where an application can be called back after painting has completed, avoiding the danger of deadlock. </p><DD><DL>
<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/Display.html#callSerially(java.lang.Runnable)"><CODE>Display.callSerially(Runnable)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="showNotify()"><!-- --></A><H3>
showNotify</H3>
<PRE>
protected void <B>showNotify</B>()</PRE>
<DL>
<DD>The implementation calls <code>showNotify()</code> immediately prior to this <code>Canvas</code> being made visible on the display. Canvas subclasses may override this method to perform tasks before being shown, such as setting up animations, starting timers, etc. The default implementation of this method in class <code>Canvas</code> is empty.</DL>
<HR>
<A NAME="hideNotify()"><!-- --></A><H3>
hideNotify</H3>
<PRE>
protected void <B>hideNotify</B>()</PRE>
<DL>
<DD>The implementation calls <code>hideNotify()</code> shortly after the <code>Canvas</code> has been removed from the display. <code>Canvas</code> subclasses may override this method in order to pause animations, revoke timers, etc. The default implementation of this method in class <code>Canvas</code> is empty.</DL>
<HR>
<A NAME="paint(javax.microedition.lcdui.Graphics)"><!-- --></A><H3>
paint</H3>
<PRE>
protected abstract void <B>paint</B>(<A HREF="../../../javax/microedition/lcdui/Graphics.html">Graphics</A> g)</PRE>
<DL>
<DD>Renders the <code>Canvas</code>. The application must implement this method in order to paint any graphics. <p>The <code>Graphics</code> object's clip region defines the area of the screen that is considered to be invalid. A correctly-written <code>paint()</code> routine must paint <em>every</em> pixel within this region. This is necessary because the implementation is not required to clear the region prior to calling <code>paint()</code> on it. Thus, failing to paint every pixel may result in a portion of the previous screen image remaining visible. </p> <p>Applications <em>must not</em> assume that they know the underlying source of the <code>paint()</code> call and use this assumption to paint only a subset of the pixels within the clip region. The reason is that this particular <code>paint()</code> call may have resulted from multiple <code>repaint()</code> requests, some of which may have been generated from outside the application. An application that paints only what it thinks is necessary to be painted may display incorrectly if the screen contents had been invalidated by, for example, an incoming telephone call. </p> <p>Operations on this graphics object after the <code>paint() </code>call returns are undefined. Thus, the application <em>must not</em> cache this <code>Graphics</code> object for later use or use by another thread. It must only be used within the scope of this method. </p> <p>The implementation may postpone visible effects of graphics operations until the end of the paint method.</p> <p> The contents of the <code>Canvas</code> are never saved if it is hidden and then is made visible again. Thus, shortly after <code>showNotify()</code> is called, <code>paint()</code> will always be called with a <code>Graphics</code> object whose clip region specifies the entire displayable area of the <code>Canvas</code>. Applications <em>must not</em> rely on any contents being preserved from a previous occasion when the <code>Canvas</code> was current. This call to <code>paint()</code> will not necessarily occur before any other key or pointer methods are called on the <code>Canvas</code>. Applications whose repaint recomputation is expensive may create an offscreen <code>Image</code>, paint into it, and then draw this image on the <code>Canvas</code> when <code>paint()</code> is called. </p> <P>The application code must never call <code>paint()</code>; it is called only by the implementation.</P> <P>The <code>Graphics</code> object passed to the <code>paint()</code> method has the following properties:</P> <UL> <LI>the destination is the actual display, or if double buffering is in effect, a back buffer for the display;</LI> <LI>the clip region includes at least one pixel within this <code>Canvas</code>;</LI> <LI>the current color is black;</LI> <LI>the font is the same as the font returned by <A HREF="../../../javax/microedition/lcdui/Font.html#getDefaultFont()"><CODE>Font.getDefaultFont()</CODE></A>;</LI> <LI>the stroke style is <A HREF="../../../javax/microedition/lcdui/Graphics.html#SOLID"><CODE>SOLID</CODE></A>;</LI> <LI>the origin of the coordinate system is located at the upper-left corner of the <code>Canvas</code>; and</LI> <LI>the <code>Canvas</code> is visible, that is, a call to <code>isShown()</code> will return <code>true</code>.</LI> </UL><DD><DL>
<DT><B>Parameters:</B><DD><CODE>g</CODE> - the <code>Graphics</code> object to be used for rendering the <code>Canvas</code></DL>
</DD>
</DL>
<HR>
<A NAME="sizeChanged(int, int)"><!-- -
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -