public class SwingTimer extends Object implements Runnable
Try changing the size of the window to see how it affects the relationship between the button and the panel where the graphics are generated.
Modifier and Type | Class and Description |
---|---|
protected class |
SwingTimer.Listener1
Action listener for this application for the
buttons in this application.
|
protected class |
SwingTimer.Listener2
Key listener for this application.
|
protected class |
SwingTimer.Motion
Executed each time the timer triggers an event.
|
protected class |
SwingTimer.MyPanel
This subclass of JPanel represents the
panel where the graphics are displayed.
|
Modifier and Type | Field and Description |
---|---|
protected FlowLayout |
layout |
protected JFrame |
mainFrame |
protected SwingTimer.MyPanel |
panel |
protected Random |
random |
protected Timer |
timer
Timer object for this application.
|
protected int |
xPos
x-coordinate of red dot in pixels.
|
protected int |
yPos
y-coordinate of red dot in pixels.
|
Constructor and Description |
---|
SwingTimer() |
Modifier and Type | Method and Description |
---|---|
protected void |
buildFrame()
Creates and sets up components in frame.
|
static void |
main(String[] args)
Main driver.
|
void |
run()
This method is triggered by the Swing utilities.
|
protected FlowLayout layout
protected SwingTimer.MyPanel panel
protected int xPos
protected int yPos
public SwingTimer()
public void run()
protected void buildFrame()
Copyright © 2017. All rights reserved.