public class SwingAnimator extends java.lang.Object implements Animator
Animator
, using a JFrame
to display the animation. The JFrame
is created and
displayed by the constructor.
Calls to update()
result in a call to
painter.paint()
. This is executed in the swing
thread while the main thread is paused for delay
milliseconds.Modifier and Type | Class and Description |
---|---|
private static class |
SwingAnimator.ContentPane
A component for painting.
|
Modifier and Type | Field and Description |
---|---|
private SwingAnimator.ContentPane |
content |
private int |
delay |
private boolean |
disposed |
private javax.swing.JFrame |
frame |
Constructor and Description |
---|
SwingAnimator(SwingAnimatorPainter painter,
java.lang.String name,
int width,
int height,
int delay)
Creates and displays a
JFrame for the animation. |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Throw away this visualization.
|
void |
update(java.util.Observable model,
java.lang.Object ignored)
Calls to
update are executed in the swing thread,
while the main thread is paused for delay
milliseconds. |
private int delay
private javax.swing.JFrame frame
private SwingAnimator.ContentPane content
private boolean disposed
public SwingAnimator(SwingAnimatorPainter painter, java.lang.String name, int width, int height, int delay)
JFrame
for the animation.name
- The name to be displayed on the graphical window.width
- The width of the display, in pixels.height
- The height of the display, in pixels.delay
- Time to pause after an update, in milliseconds.public void dispose()
public void update(java.util.Observable model, java.lang.Object ignored)
update
are executed in the swing thread,
while the main thread is paused for delay
milliseconds.update
in interface java.util.Observer