Methods Summary |
---|
public boolean | awaitPaint()Waits until this canvas is painted for the first time. Proper operation
relies on the caller to have arranged for this canvas to be shown, for
example, with setCurrent(). Returns immediately if the canvas has been
painted already, even if it's been hidden and shown again. Returns true
if the canvas has been painted at least once. Returns false if the wait
was interrupted or if it timed out. This method must not be called on
the event thread. If it is, it will block paint processing and will
eventually timeout.
long deadline = System.currentTimeMillis() + TIMEOUT;
synchronized (this) {
try {
while (!painted && System.currentTimeMillis() < deadline) {
wait(TIMEOUT);
}
} catch (InterruptedException ie) {
return false;
}
return painted;
}
|
public boolean | awaitShow()Waits until this canvas is shown for the first time. Proper operation
relies on the caller to have arranged for this canvas to be shown, for
example, with setCurrent(). Returns immediately if the canvas has been
shown already, even if it has subsequently been hidden. Returns true if
the canvas has ever been shown. Returns false if the wait was
interrupted or if it timed out. This method must not be called on the
event thread. If it is, it will block show processing and will
eventually timeout.
long deadline = System.currentTimeMillis() + TIMEOUT;
synchronized (this) {
try {
while (!everShown && System.currentTimeMillis() < deadline) {
wait(TIMEOUT);
}
} catch (InterruptedException ie) {
return false;
}
return everShown;
}
|
public final void | hideNotify()Tracks the shown state. This is made final so that subclassers can't
accidentally break the protocol if they override and forget to call
super(). Subclassers may override hideNotify1() if they wish to do hide
processing.
synchronized (this) {
shown = false;
}
hideNotify1();
|
public void | hideNotify1()Subclassers should override this to do hideNotify() processing.
|
public final void | paint(javax.microedition.lcdui.Graphics g)Notifies when painted for the first time. This is made final so that
subclassers can't accidentally break this if they override and forget
to call super(). Subclassers should override paint1() to do actual
painting.
synchronized (this) {
if (!painted) {
painted = true;
notifyAll();
}
}
paint1(g);
|
public void | paint1(javax.microedition.lcdui.Graphics g)Subclassers should override this to do actual painting.
|
public synchronized boolean | showCalled()Returns a boolean indicating whether showNotify has been called on this
canvas more recently than hideNotify. This differs from the
Displayable.isShown() method, which checks the internal state of the
Displayable object.
return shown;
|
public final void | showNotify()Tracks the shown state. If this is the first time the Canvas is being
shown, sets everShown and does a monitor notify. This is made final so
that subclassers can't accidentally break the protocol if they override
and forget to call super(). Subclassers may override showNotify1() if
they wish to do show processing.
synchronized (this) {
shown = true;
if (!everShown) {
everShown = true;
notifyAll();
}
}
showNotify1();
|
public void | showNotify1()Subclassers should override this to do showNotify() processing.
|
public synchronized boolean | wasShown()Returns a boolean indicating whether showNotify() has ever been called
at any time since the canvas was created.
return everShown;
|