|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
ballworlds.framework.WorldPanel
public class WorldPanel
A WorldPanel displays its associated World and the Balls in that World.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static Color |
SELECTED_BALL_COLOR
Color of the selected Ball. |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
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 | |
---|---|
WorldPanel(Dimension size,
Color color,
World world)
Makes this panel respond to mouse actions and repeatedly repaint itself. |
Method Summary | |
---|---|
void |
mouseClicked(MouseEvent event)
Toggles the nearest Ball between the paused and not-paused state. |
void |
mouseDragged(MouseEvent event)
For the selected Ball (if any), moves the Ball to the current mouse point. |
void |
mouseEntered(MouseEvent event)
Does nothing. |
void |
mouseExited(MouseEvent event)
Does nothing. |
void |
mouseMoved(MouseEvent event)
Does nothing. |
void |
mousePressed(MouseEvent event)
Sets the selected Ball to the Ball nearest the mouse point. |
void |
mouseReleased(MouseEvent event)
Sets the selected Ball to null (i.e., no Ball is selected). |
void |
paintComponent(Graphics g)
Draws the World and its Balls. |
void |
run()
Repeatedly repaints this panel. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Color SELECTED_BALL_COLOR
Constructor Detail |
---|
public WorldPanel(Dimension size, Color color, World world)
size
- size of this panel.color
- Background color for this WorldPanel.world
- the World associated with this WorldPanel.Method Detail |
---|
public void paintComponent(Graphics g)
paintComponent
in class JComponent
g
- the Graphics object onto which to draw.public void mousePressed(MouseEvent event)
mousePressed
in interface MouseListener
event
- The MouseEvent that caused this method to be invoked.public void mouseReleased(MouseEvent event)
mouseReleased
in interface MouseListener
event
- The MouseEvent that caused this method to be invoked.public void mouseEntered(MouseEvent event)
mouseEntered
in interface MouseListener
event
- The MouseEvent that caused this method to be invoked.public void mouseExited(MouseEvent event)
mouseExited
in interface MouseListener
event
- The MouseEvent that caused this method to be invoked.public void mouseClicked(MouseEvent event)
mouseClicked
in interface MouseListener
event
- The MouseEvent that caused this method to be invoked.public void mouseDragged(MouseEvent event)
mouseDragged
in interface MouseMotionListener
event
- The MouseEvent that caused this method to be invoked.public void mouseMoved(MouseEvent event)
mouseMoved
in interface MouseMotionListener
event
- The MouseEvent that caused this method to be invoked.public void run()
run
in interface Runnable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |