yops
Class BasicGraphicsPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JLayeredPane
                  extended by yops.BasicGraphicsPanel
All Implemented Interfaces:
MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible
Direct Known Subclasses:
GraphicsPanel

public class BasicGraphicsPanel
extends JLayeredPane
implements MouseListener, MouseMotionListener

A GraphicsPanel is a container in which graphics components can be displayed.

Author:
Kenneth J. Goldman
Created Jul 5, 2005
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JLayeredPane
JLayeredPane.AccessibleJLayeredPane
 
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.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JLayeredPane
DEFAULT_LAYER, DRAG_LAYER, FRAME_CONTENT_LAYER, LAYER_PROPERTY, MODAL_LAYER, PALETTE_LAYER, POPUP_LAYER
 
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
BasicGraphicsPanel(int width, int height)
          Creates a GraphicsPanel with the given dimensions.
 
Method Summary
 Component add(Component c)
          Adds the given component to the GraphicsPanel for display.
 void clear()
          Removes all components from the GraphicsPanel, except for the background image.
 Image getMainImage()
          Gets the background image of this graphics panel.
 void mouseClicked(MouseEvent me)
          This method is called by the Java event loop when mouse events occur.
 void mouseDragged(int x, int y)
          This method will be called whenever the user moves the mouse within the panel while holding down a mouse button.
 void mouseDragged(MouseEvent me)
          This method is called by the Java event loop when mouse events occur.
 void mouseEntered(MouseEvent me)
          This method is called by the Java event loop when mouse events occur.
 void mouseExited(MouseEvent me)
          This method is called by the Java event loop when mouse events occur.
 void mouseMoved(int x, int y)
          This method will be called whenever the user moves the mouse within the panel.
 void mouseMoved(MouseEvent me)
          This method is called by the Java event loop when mouse events occur.
 void mousePressed(int x, int y)
          This method will be called whenever the user pressses the mouse button on the panel.
 void mousePressed(MouseEvent me)
          This method is called by the Java event loop when mouse events occur.
 void mouseReleased(int x, int y)
          This method will be called whenever the user releases the mouse button, provided that the mouse button had been pressed within the panel.
 void mouseReleased(MouseEvent me)
          This method is called by the Java event loop when mouse events occur.
 void moveToBack(Component arg0)
          Places the given component behind all other components.
 void moveToFront(Component arg0)
          Places the given component in front of all other components.
 void remove(Component c)
          Removes the given component from the GraphicsPanel.
 
Methods inherited from class javax.swing.JLayeredPane
addImpl, getAccessibleContext, getComponentCountInLayer, getComponentsInLayer, getComponentToLayer, getIndexOf, getLayer, getLayer, getLayeredPaneAbove, getObjectForLayer, getPosition, highestLayer, insertIndexForLayer, isOptimizedDrawingEnabled, lowestLayer, paint, paramString, putLayer, remove, removeAll, setLayer, setLayer, setPosition
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicGraphicsPanel

public BasicGraphicsPanel(int width,
                          int height)
Creates a GraphicsPanel with the given dimensions.

Parameters:
width - in pixels
height - in pixels
Method Detail

add

public Component add(Component c)
Adds the given component to the GraphicsPanel for display.

Overrides:
add in class Container

remove

public void remove(Component c)
Removes the given component from the GraphicsPanel.

Overrides:
remove in class Container

clear

public void clear()
Removes all components from the GraphicsPanel, except for the background image.


moveToBack

public void moveToBack(Component arg0)
Places the given component behind all other components.

Overrides:
moveToBack in class JLayeredPane

moveToFront

public void moveToFront(Component arg0)
Places the given component in front of all other components.

Overrides:
moveToFront in class JLayeredPane

getMainImage

public Image getMainImage()
Gets the background image of this graphics panel.

Returns:
the background image

mousePressed

public void mousePressed(int x,
                         int y)
This method will be called whenever the user pressses the mouse button on the panel.

Parameters:
x - in pixels
y - in pixels

mouseReleased

public void mouseReleased(int x,
                          int y)
This method will be called whenever the user releases the mouse button, provided that the mouse button had been pressed within the panel.

Parameters:
x - in pixels
y - in pixels

mouseMoved

public void mouseMoved(int x,
                       int y)
This method will be called whenever the user moves the mouse within the panel.

Parameters:
x - in pixels
y - in pixels

mouseDragged

public void mouseDragged(int x,
                         int y)
This method will be called whenever the user moves the mouse within the panel while holding down a mouse button.

Parameters:
x - in pixels
y - in pixels

mouseClicked

public void mouseClicked(MouseEvent me)
This method is called by the Java event loop when mouse events occur. You should not call this method directly.

Specified by:
mouseClicked in interface MouseListener

mouseDragged

public void mouseDragged(MouseEvent me)
This method is called by the Java event loop when mouse events occur. You should not call this method directly.

Specified by:
mouseDragged in interface MouseMotionListener

mouseEntered

public void mouseEntered(MouseEvent me)
This method is called by the Java event loop when mouse events occur. You should not call this method directly.

Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent me)
This method is called by the Java event loop when mouse events occur. You should not call this method directly.

Specified by:
mouseExited in interface MouseListener

mouseMoved

public void mouseMoved(MouseEvent me)
This method is called by the Java event loop when mouse events occur. You should not call this method directly.

Specified by:
mouseMoved in interface MouseMotionListener

mousePressed

public void mousePressed(MouseEvent me)
This method is called by the Java event loop when mouse events occur. You should not call this method directly.

Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent me)
This method is called by the Java event loop when mouse events occur. You should not call this method directly.

Specified by:
mouseReleased in interface MouseListener