public class TurtleFrame extends javax.swing.JFrame implements TurtleContainer, java.awt.event.FocusListener
Playground
where the
Turtle
s lives.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
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Constructor and Description |
---|
TurtleFrame()
Creates a window with default title.
|
TurtleFrame(java.awt.Color bkColor)
Creates a window with default title and give background color.
|
TurtleFrame(int mode)
Creates a window with given mode.
|
TurtleFrame(int mode,
int ulx,
int uly,
java.lang.String title,
javax.swing.JMenuBar menuBar,
int width,
int height,
java.awt.Color bkColor)
Creates a window with given mode, r, g, title, JMenuBar,
width, height and background color.
|
TurtleFrame(int ulx,
int uly,
java.lang.String title)
Creates a window with given r, g and title.
|
TurtleFrame(int ulx,
int uly,
java.lang.String title,
int width,
int height)
Creates a window with given r, g, title, playground width and height.
|
TurtleFrame(int ulx,
int uly,
java.lang.String title,
int width,
int height,
java.awt.Color bkColor)
Creates a window with given r, g, title, playground width, height
and background color.
|
TurtleFrame(int ulx,
int uly,
java.lang.String title,
javax.swing.JMenuBar menuBar,
int width,
int height,
java.awt.Color bkColor)
Creates a window with given r, g, title, JMenuBar, playground width,
height and background color.
|
TurtleFrame(int mode,
java.lang.String title,
int width,
int height,
java.awt.Color bkColor)
Creates a window with given mode, title, width, height and background color.
|
TurtleFrame(javax.swing.JMenuBar menuBar)
Creates a window with default title and given JMenuBar.
|
TurtleFrame(java.lang.String title)
Creates a window with given title.
|
TurtleFrame(java.lang.String title,
java.awt.Color bkColor)
Creates a window with given title and background color.
|
TurtleFrame(java.lang.String title,
int width,
int height)
Creates a window with given title, playground width and height.
|
TurtleFrame(java.lang.String title,
int width,
int height,
java.awt.Color bkColor)
Creates a window with given title, playground width, height and background color.
|
TurtleFrame(java.lang.String title,
javax.swing.JMenuBar menuBar)
Creates a window with given title and JMenuBar.
|
TurtleFrame(java.lang.String title,
javax.swing.JMenuBar menuBar,
java.awt.Color bkColor)
Creates a window with given title, JMenuBar and background color.
|
TurtleFrame(java.lang.String title,
javax.swing.JMenuBar menuBar,
int width,
int height)
Creates a window with given title, JMenuBar, playground width and height.
|
TurtleFrame(java.lang.String title,
javax.swing.JMenuBar menuBar,
int width,
int height,
java.awt.Color bkColor)
Creates a window with given title, JMenuBar, playground width, height
and background color.
|
Modifier and Type | Method and Description |
---|---|
void |
addExitListener(ExitListener exitListener)
Adds the specified ExitListener to get a notification when the close button is clicked.
|
void |
addKeyListener(java.awt.event.KeyListener listener)
Adds the specified KeyListener to receive key events.
|
void |
addMouseDoubleClickListener(MouseDoubleClickListener listener)
Adds the specified MouseDoubleClickListener to receive mouse events
and calls setDoubleClickDelay(-1).
|
void |
addMouseHitListener(MouseHitListener listener)
Registers a MouseHitListener to report mouse press events
each in a separate thread.
|
void |
addMouseHitXListener(MouseHitXListener listener)
Registers a MouseHitXListener to report mouse press events
each in a separate thread.
|
void |
addMouseListener(java.awt.event.MouseListener listener)
Adds the specified MouseListener to receive mouse events.
|
void |
addMouseMotionListener(java.awt.event.MouseMotionListener listener)
Adds the specified MouseMotionListener to receive mouse events.
|
void |
addMouseWheelListener(java.awt.event.MouseWheelListener listener)
Adds the specified MouseWheelListener to receive mouse events.
|
void |
addStatusBar(int height)
Adds the status window attached at the bottom of the game grid window.
|
void |
dispose()
Release all used system resources.
|
void |
drawBkImage(java.lang.String filename)
Draws the given image into the background (trace buffer).
|
void |
focusGained(java.awt.event.FocusEvent evt)
Empty implementation of a FocusListener method.
|
void |
focusLost(java.awt.event.FocusEvent evt)
For standalone applets we must put the applet window in front of the browser.
|
int |
getDoubleClickDelay()
Returns the current double-click delay.
|
char |
getKey()
Returns the unicode character associated with last key typed.
|
int |
getKeyCode()
Returns the key code associated with last key pressed.
|
int |
getKeyCodeWait()
Waits until a key is typed and
returns the key code associated with last key pressed.
|
char |
getKeyWait()
Waits until a key is typed and
returns the unicode character associated with it.
|
static TurtleFrame |
getLastFrame()
Returns the last frame of all initialized frames.
|
static java.awt.Point |
getLastScreenLocation()
Returns the location of the last window
(null if not yet visible).
|
int |
getModifiers()
Returns the modifiers associated with last key pressed.
|
java.lang.String |
getModifiersText()
Returns the modifiers associated with last key pressed.
|
int |
getMouseHitButton()
Returns the number of the last mouse button from a registered
mouseHit or mouseHitX event.
|
Playground |
getPlayground()
Returns the playground of this TurtleFrame.
|
java.awt.Point |
getScreenLocation()
Returns the current location of the window on the screen.
|
static boolean |
isDisposed()
Checks if the turtle frame was disposed or released.
|
boolean |
kbhit()
Returns true, if a key was typed
since the last call to getChar() or getCharWait().
|
void |
setClosingMode(int mode)
Determines what happens when the title bar close button is hit.
|
void |
setCursor(int cursorType)
Sets the mouse cursor image.
|
java.awt.Dimension |
setCustomCursor(java.lang.String cursorImage)
Same as setCustomCursor(cursorImage, hotSpot) with
hotSpot in center of image.
|
java.awt.Dimension |
setCustomCursor(java.lang.String cursorImage,
java.awt.Point hotSpot)
Sets the mouse cursor image to a custom icon.
|
void |
setDoubleClickDelay(int delay)
Sets the time delay the system uses to distinct click and double-click
mouse events.
|
java.awt.Point |
setScreenLocation(java.awt.Point location)
Sets the location of the window on the screen and returns the old location.
|
void |
setStatusText(java.lang.String text)
Replaces the text in the status bar by the given text using the current
JOptionPane font and color.
|
void |
setStatusText(java.lang.String text,
java.awt.Font font,
java.awt.Color color)
Replaces the text in the status bar by the given text using the given font
and text color.
|
void |
showStatusBar(boolean show)
Shows or hides the status bar.
|
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setTransferHandler, update
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
add, 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, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, 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, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public TurtleFrame()
public TurtleFrame(java.lang.String title)
public TurtleFrame(javax.swing.JMenuBar menuBar)
public TurtleFrame(java.lang.String title, javax.swing.JMenuBar menuBar)
public TurtleFrame(java.awt.Color bkColor)
public TurtleFrame(java.lang.String title, java.awt.Color bkColor)
public TurtleFrame(java.lang.String title, javax.swing.JMenuBar menuBar, java.awt.Color bkColor)
public TurtleFrame(java.lang.String title, int width, int height)
public TurtleFrame(java.lang.String title, int width, int height, java.awt.Color bkColor)
public TurtleFrame(java.lang.String title, javax.swing.JMenuBar menuBar, int width, int height)
public TurtleFrame(java.lang.String title, javax.swing.JMenuBar menuBar, int width, int height, java.awt.Color bkColor)
public TurtleFrame(int ulx, int uly, java.lang.String title)
public TurtleFrame(int ulx, int uly, java.lang.String title, int width, int height)
public TurtleFrame(int ulx, int uly, java.lang.String title, int width, int height, java.awt.Color bkColor)
public TurtleFrame(int ulx, int uly, java.lang.String title, javax.swing.JMenuBar menuBar, int width, int height, java.awt.Color bkColor)
public TurtleFrame(int mode)
public TurtleFrame(int mode, java.lang.String title, int width, int height, java.awt.Color bkColor)
public TurtleFrame(int mode, int ulx, int uly, java.lang.String title, javax.swing.JMenuBar menuBar, int width, int height, java.awt.Color bkColor)
public static TurtleFrame getLastFrame()
public Playground getPlayground()
getPlayground
in interface TurtleContainer
public void focusLost(java.awt.event.FocusEvent evt)
focusLost
in interface java.awt.event.FocusListener
public void focusGained(java.awt.event.FocusEvent evt)
focusGained
in interface java.awt.event.FocusListener
public void addStatusBar(int height)
public void setStatusText(java.lang.String text)
public void setStatusText(java.lang.String text, java.awt.Font font, java.awt.Color color)
public void showStatusBar(boolean show)
public void addMouseListener(java.awt.event.MouseListener listener)
addMouseListener
in class java.awt.Component
listener
- the registered MouseListenerpublic void addMouseMotionListener(java.awt.event.MouseMotionListener listener)
addMouseMotionListener
in class java.awt.Component
listener
- the registered MouseMotionListenerpublic void addMouseDoubleClickListener(MouseDoubleClickListener listener)
listener
- the registered MouseDoubleClickListenerpublic void addKeyListener(java.awt.event.KeyListener listener)
addKeyListener
in class java.awt.Component
listener
- the registered KeyListenerpublic void addMouseWheelListener(java.awt.event.MouseWheelListener listener)
addMouseWheelListener
in class java.awt.Component
listener
- the registered MouseWheelListenerpublic void addExitListener(ExitListener exitListener)
public void dispose()
dispose
in class java.awt.Window
public static boolean isDisposed()
public void addMouseHitListener(MouseHitListener listener)
public void addMouseHitXListener(MouseHitXListener listener)
public boolean kbhit()
public char getKey()
public int getKeyCode()
public char getKeyWait()
public int getKeyCodeWait()
public int getModifiers()
public java.lang.String getModifiersText()
public void setCursor(int cursorType)
setCursor
in class java.awt.Frame
cursorType
- one of the constants in class java.awt.Cursorpublic java.awt.Dimension setCustomCursor(java.lang.String cursorImage, java.awt.Point hotSpot)
cursorImage
- the path to the image filehotSpot
- the image point that reports the mouse
location (origin in upper left corner). Must be inside the custom image.public java.awt.Dimension setCustomCursor(java.lang.String cursorImage)
cursorImage
- the path to the image filepublic void setClosingMode(int mode)
public void setDoubleClickDelay(int delay)
delay
- the double-click delay time in milliseconds used when a
double-click event is registeredpublic void drawBkImage(java.lang.String filename)
filename
- the file name or urlpublic int getDoubleClickDelay()
public int getMouseHitButton()
public java.awt.Point setScreenLocation(java.awt.Point location)
public java.awt.Point getScreenLocation()
public static java.awt.Point getLastScreenLocation()