|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Canvas javax.swing.SystemEventQueueUtilities.RunnableCanvas
Applets don't have direct access to the AWT SystemEvent queue. To work around this we call RunnableCanvas.repaint() on a per applet instance of this class. The AWT deals with this by queuing a java.awt.PaintEvent for the event dispatching thread which is dispatched (Component.dispatchEvent()) the usual way. Component.dispatchEvent() handles PaintEvents by calling our update() method (on the event dispatching thread) which processes the RunnableEvents stashed in the runnableEvents vector.
Nested Class Summary |
Nested classes inherited from class java.awt.Canvas |
Canvas.AccessibleAWTCanvas |
Nested classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
private boolean |
isRegistered
|
private static Graphics |
nullGraphics
|
private static Hashtable |
runnableCanvasTable
|
private Vector |
runnableEvents
|
Fields inherited from class java.awt.Canvas |
|
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
(package private) |
SystemEventQueueUtilities.RunnableCanvas(JRootPane rootPane)
|
Method Summary | |
(package private) void |
addRunnableEvent(SystemEventQueueUtilities.RunnableEvent e)
Add a RunnableEvent to the queue that will be dispatched when this component is repainted. |
Graphics |
getGraphics()
Reduce the cost of repainting (since we're not going to draw anything) by returning a constant no-op graphics object. |
Dimension |
getPreferredSize()
Testing purposes only. |
private SystemEventQueueUtilities.RunnableEvent[] |
getRunnableCanvasEvents()
Return an (array) copy of the runnableEvents vector or null if the vector is empty. |
boolean |
isShowing()
If there are events to be processed then we're showing. |
(package private) static SystemEventQueueUtilities.RunnableCanvas |
lookup(SystemEventQueueUtilities.RunnableEvent e)
If we're running on the event dispatching thread then lookup the canvas with the current thread itself, otherwise use the current threads thread group. |
private void |
maybeRegisterEventDispatchThread()
If called on an event dispatching thread that we haven't seen before then make two hashtable entries in the runnableCanvasTable: current thread => this RunnableCanvas current thread group => this RunnableCanvas |
void |
paint(Graphics g)
Paints this canvas. |
(package private) static void |
postRunnableEventToAll(SystemEventQueueUtilities.RunnableEvent e)
Adds the event to all the RunnableCanvases. |
(package private) static void |
remove(JRootPane rootPane)
Remove the RunnableCanvas associated with this applet from the applets Layered pane and clear all of the runnableCanvasTable entries that point at it. |
void |
update(Graphics g)
Process all of the RunnableEvents that have accumulated since RunnableCanvas.repaint() was called. |
Methods inherited from class java.awt.Canvas |
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final Graphics nullGraphics
private static Hashtable runnableCanvasTable
private Vector runnableEvents
private boolean isRegistered
Constructor Detail |
SystemEventQueueUtilities.RunnableCanvas(JRootPane rootPane)
Method Detail |
private void maybeRegisterEventDispatchThread()
current thread => this RunnableCanvas current thread group => this RunnableCanvas
lookup(javax.swing.SystemEventQueueUtilities.RunnableEvent)
static SystemEventQueueUtilities.RunnableCanvas lookup(SystemEventQueueUtilities.RunnableEvent e)
static void postRunnableEventToAll(SystemEventQueueUtilities.RunnableEvent e)
SystemEventQueueUtilities.restartTimerQueueThread()
static void remove(JRootPane rootPane)
public boolean isShowing()
isShowing
in class Component
true
if the component is showing,
false
otherwiseComponent.setVisible(boolean)
public Graphics getGraphics()
getGraphics
in class Component
null
if it has noneComponent.paint(java.awt.Graphics)
public Dimension getPreferredSize()
getPreferredSize
in class Component
Component.getMinimumSize()
,
LayoutManager
void addRunnableEvent(SystemEventQueueUtilities.RunnableEvent e)
update(java.awt.Graphics)
private SystemEventQueueUtilities.RunnableEvent[] getRunnableCanvasEvents()
update(java.awt.Graphics)
public void paint(Graphics g)
Canvas
Most applications that subclass Canvas
should
override this method in order to perform some useful operation
(typically, custom painting of the canvas).
The default operation is simply to clear the canvas.
Applications that override this method need not call
super.paint(g).
paint
in class Canvas
g
- the specified Graphics contextCanvas.update(Graphics)
,
Component.paint(Graphics)
public void update(Graphics g)
update
in class Canvas
g
- the specified Graphics contextCanvas.paint(Graphics)
,
Component.update(Graphics)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |