|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container java.awt.Window java.awt.Frame javax.swing.JFrame edu.southern.computing.oopj.Viewport
public class Viewport
A convenience superclass for creating simple graphical applications.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JFrame |
---|
javax.swing.JFrame.AccessibleJFrame |
Nested classes/interfaces inherited from class java.awt.Frame |
---|
java.awt.Frame.AccessibleAWTFrame |
Nested classes/interfaces inherited from class java.awt.Window |
---|
java.awt.Window.AccessibleAWTWindow |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class javax.swing.JFrame |
---|
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled |
Fields inherited from class java.awt.Frame |
---|
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface edu.southern.computing.oopj.InteractiveArea |
---|
BLACK, BLUE, CROSSHAIR, CYAN, DARK_GRAY, GRAY, GREEN, HAND, LIGHT_GRAY, MAGENTA, MOVE, ORANGE, PINK, RED, TRANSPARENT, VERSION, WHITE, YELLOW |
Fields inherited from interface javax.swing.WindowConstants |
---|
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
Viewport(java.lang.String title,
int x,
int y,
int width,
int height)
Creates a new application window. |
Method Summary | |
---|---|
java.awt.Component |
add(java.awt.Component c)
Adds a graphical component to the viewport. |
void |
clear()
Clears the viewport, erasing any existing drawings |
void |
draw()
Renders the contents of the viewport. |
void |
draw(java.awt.Graphics g)
Sets the transient graphics context and then calls the no-parameter version of draw(). |
void |
drawLine(int startX,
int startY,
int endX,
int endY)
Draws a line with the current color. |
void |
drawLine(int startX,
int startY,
int endX,
int endY,
java.awt.Color color)
Draws a line with the given color. |
void |
drawOval(int left,
int top,
int width,
int height)
Draws an oval with the current drawing color. |
void |
drawPoint(double x,
double y)
Draws a point (pixel) with the current color. |
void |
drawPoint(int x,
int y)
Draws a point (pixel) with the current color. |
void |
drawPoint(int x,
int y,
java.awt.Color color)
Draws a point (pixel) with the given color. |
void |
drawPolygon(int... coords)
Draws a polygon with the current color. |
void |
drawRectangle(double left,
double top,
double width,
double height)
Draws a rectangle with double-precision floating point coordinates. |
void |
drawRectangle(int left,
int top,
int width,
int height)
Draws a rectangle with the current drawing color. |
void |
drawString(java.lang.String message,
int x,
int y)
Draws a string with the current color. |
void |
fillOval(int left,
int top,
int width,
int height)
Paints a filled oval with the current color. |
void |
fillOval(int left,
int top,
int width,
int height,
java.awt.Color color)
Paints a filled oval with the given color. |
void |
fillPolygon(int... coords)
Paints a filled polygon with the current color. |
void |
fillRectangle(int left,
int top,
int width,
int height)
Paints a filled rectangle with the current color. |
void |
fillRectangle(int left,
int top,
int width,
int height,
java.awt.Color color)
Paints a filled rectangle with the given color. |
char |
getKeyTyped()
Returns the key typed by the user during the last keyboard interaction event. |
int |
getMouseX()
Returns the x position of the latest mouse event. |
int |
getMouseY()
Returns the y position of the latest mouse event. |
javax.swing.JPanel |
getViewportPanel()
Returns the underlying content pane of the viewport. |
void |
keyPressed(java.awt.event.KeyEvent e)
Called when the user presses a key when the viewport has keyboard focus. |
void |
keyReleased(java.awt.event.KeyEvent e)
Called when the user releases a key when the viewport has keyboard focus. |
void |
keyTyped()
Called when the user types (presses and releases) a key when the viewport has keyboard focus. |
void |
keyTyped(java.awt.event.KeyEvent e)
Called when the user types (presses and releases) a key when the viewport has keyboard focus. |
void |
mouseClicked()
Called when the mouse button is clicked (pressed and released) while the mouse pointer is within the viewport area. |
void |
mouseClicked(java.awt.event.MouseEvent e)
Called when the mouse is clicked (pressed and released). |
void |
mouseDragged()
Called when the mouse is after its button was depressed over the viewport. |
void |
mouseDragged(java.awt.event.MouseEvent e)
Called when the mouse is moved when the button is down. |
void |
mouseEntered()
Called when the mouse pointer enters the viewport's area. |
void |
mouseEntered(java.awt.event.MouseEvent e)
Called when the mouse pointer enters the component. |
void |
mouseExited()
Called when the mouse pointer exits the viewport's area. |
void |
mouseExited(java.awt.event.MouseEvent e)
Called when the mouse pointer exits the component. |
void |
mouseMoved()
Called when the mouse is moved over the viewport and no buttons are depressed. |
void |
mouseMoved(java.awt.event.MouseEvent e)
Called when the mouse is moved without a button depressed. |
void |
mousePressed()
Called when the mouse button is depressed over the component. |
void |
mousePressed(java.awt.event.MouseEvent e)
Called when the mouse button is pressed. |
void |
mouseReleased()
Called when the mouse button is released over the viewport. |
void |
mouseReleased(java.awt.event.MouseEvent e)
Called when the mouse button is released. |
void |
setBackground(java.awt.Color color)
Sets the background color for the display area of the viewport. |
void |
setBoxLayout(int orient)
Sets the layout manager for the drawing area the BoxLayout. |
void |
setColor(java.awt.Color color)
Draws a rectangle with the current drawing color. |
void |
setContextMenu(ContextMenu menu)
Sets the context-sensitive popup menu for the viewport. |
Methods inherited from class javax.swing.JFrame |
---|
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update |
Methods inherited from class java.awt.Frame |
---|
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated |
Methods inherited from class java.awt.Window |
---|
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.awt.MenuContainer |
---|
getFont, postEvent |
Constructor Detail |
---|
public Viewport(java.lang.String title, int x, int y, int width, int height)
title
- the title of the window; appears in the window's
title barx
- the x coordinate of the window's top-left
cornery
- the y coordinate of the window's top-left
cornerwidth
- the window's widthheight
- the window's heightpanel
- the application's drawing area and
application-specific functionalityMethod Detail |
---|
public void clear()
public void setColor(java.awt.Color color)
color
- the color to use as the current drawing color.public void drawPoint(int x, int y, java.awt.Color color)
x
- x coordinate of the pixel.y
- y coordinate of the pixel.color
- color of the point.public void drawPoint(int x, int y)
x
- x coordinate of the pixel.y
- y coordinate of the pixel.color
- color of the point.public void drawPoint(double x, double y)
x
- x coordinate of the pixel.y
- y coordinate of the pixel.color
- color of the point.public void drawLine(int startX, int startY, int endX, int endY, java.awt.Color color)
startX
- x coordinate of the beginning endpoint.startY
- y coordinate of the beginning endpoint.endX
- x coordinate of the ending endpoint.endY
- y coordinate of the ending endpoint.color
- color of the line.public void drawLine(int startX, int startY, int endX, int endY)
startX
- x coordinate of the beginning endpoint.startY
- y coordinate of the beginning endpoint.endX
- x coordinate of the ending endpoint.endY
- y coordinate of the ending endpoint.public void drawRectangle(int left, int top, int width, int height)
left
- the x coordinate of the rectangle's left-top corner.top
- the y coordinate of the rectangle's left-top corner.width
- the rectangle's width.height
- the rectangle's height.public void drawRectangle(double left, double top, double width, double height)
left
- the x coordinate of the rectangle's left-top corner.top
- the y coordinate of the rectangle's left-top corner.width
- the rectangle's width.height
- the rectangle's height.public void fillRectangle(int left, int top, int width, int height, java.awt.Color color)
left
- the x coordinate of the rectangle's left-top corner.top
- the y coordinate of the rectangle's left-top corner.width
- the rectangle's width.height
- the rectangle's height.color
- the fill color.public void fillRectangle(int left, int top, int width, int height)
left
- the x coordinate of the rectangle's left-top corner.top
- the y coordinate of the rectangle's left-top corner.width
- the rectangle's width.height
- the rectangle's height.public void drawOval(int left, int top, int width, int height)
left
- the x coordinate of the left-top corner of the oval's
bounding box.top
- the y coordinate of the left-top corner of the oval's
bounding box.width
- the oval's width.height
- the oval's height.public void fillOval(int left, int top, int width, int height, java.awt.Color color)
left
- the x coordinate of the left-top corner of the oval's
bounding box.top
- the y coordinate of the left-top corner of the oval's
bounding box.width
- the oval's width.height
- the oval's height.color
- the fill color.public void fillOval(int left, int top, int width, int height)
left
- the x coordinate of the left-top corner of the oval's
bounding box.top
- the y coordinate of the left-top corner of the oval's
bounding box.width
- the oval's width.height
- the oval's height.public void drawPolygon(int... coords)
public void fillPolygon(int... coords)
public void drawString(java.lang.String message, int x, int y)
message
- the string to render.x
- the x coordinate of the baseline of the string's beginning.y
- the y coordinate of the baseline.public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
e
- stores information about the mouse event (position, modifiers, etc.)public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
e
- stores information about the mouse event (position, modifiers, etc.)public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
e
- stores information about the mouse event (position, modifiers, etc.)public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
e
- stores information about the mouse event (position, modifiers, etc.)public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
e
- stores information about the mouse event (position, modifiers, etc.)public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
e
- stores information about the mouse event (position, modifiers, etc.)public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
e
- stores information about the mouse event (position, modifiers, etc.)public void mouseClicked()
public void mouseEntered()
public void mouseExited()
public void mousePressed()
public void mouseReleased()
public void mouseDragged()
public void mouseMoved()
public int getMouseX()
public int getMouseY()
public void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
public void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
public void keyTyped()
public char getKeyTyped()
public void draw(java.awt.Graphics g)
g
- the graphics context to use for rendering.public void draw()
public java.awt.Component add(java.awt.Component c)
add
in class java.awt.Container
c
- the component to add.
public javax.swing.JPanel getViewportPanel()
public void setBoxLayout(int orient)
orient
- is the orientation.public void setContextMenu(ContextMenu menu)
setContextMenu
in interface InteractiveArea
the
- context-sensitive menu to apply.public void setBackground(java.awt.Color color)
setBackground
in class java.awt.Component
color
- the background color to use
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |