public class KarelProgram extends Program
Program
that runs a Karel program.| Modifier and Type | Class and Description |
|---|---|
static class |
KarelProgram.State |
JApplet.AccessibleJAppletApplet.AccessibleAppletPanel.AccessibleAWTPanelContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
static Color |
BLACK |
static Color |
BLUE |
static Color |
CYAN |
static Color |
DARK_GRAY |
static int |
EAST |
static int |
FANCY |
static Color |
GRAY |
static Color |
GREEN |
static int |
INFINITE |
static Color |
LIGHT_GRAY |
static Color |
MAGENTA |
static int |
NORTH |
static Color |
ORANGE |
static Color |
PINK |
static Color |
RED |
static int |
SIMPLE |
static int |
SOUTH |
Event<KarelProgram.State> |
StateEvent |
static int |
WEST |
static Color |
WHITE |
static String |
WORLD_EXTENSION
File extension for Karel worlds.
|
static String |
WORLDS_DIRECTORY
Directory where *.w Karel world files are found.
|
static Color |
YELLOW |
CONFIG_FILE_NAME, invisibleObjectsaccessibleContext, rootPane, rootPaneCheckingEnabledBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTCENTERABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
KarelProgram()
Creates a new Karel program.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Karel karel) |
void |
add(KarelInterface karel,
int x,
int y,
int dir,
int nBeepers) |
protected KarelWorld |
createWorld()
Creates the
KarelWorld in which Karel lives. |
protected Karel |
getKarel() |
KarelWorld |
getWorld()
Returns the
KarelWorld object in which Karel lives. |
static String |
getWorldDirectory()
Returns the default directory in which Karel's worlds live.
|
protected boolean |
isStarted()
Checks to see whether this program has started.
|
protected void |
loadConfiguration(Properties props)
Loads any saved configuration of this program from disk.
|
void |
loadInitialWorld() |
void |
main()
Contains the code to be executed for each specific program subclass.
|
boolean |
menuAction(ActionEvent event)
Called whenever a program action is detected in the menu bar.
|
protected void |
saveConfiguration(Properties props)
Saves configuration of this program to disk in the given properties collection.
|
void |
setStatus(String status) |
protected void |
setWorld(KarelWorld world) |
protected void |
startRun()
Initializes and runs the run method.
|
actionPerformed, add, addActionListeners, addActionListeners, addActionListenersToButtonsOnly, addAllActionListeners, addExitHook, addImpl, adjustmentValueChanged, alert, alert, animation, center, changedUpdate, checkCompilerFlags, checkKill, checkStartupSettings, componentAdded, componentHidden, componentMoved, componentRemoved, componentResized, componentShown, confirm, contentsChanged, createConsole, createDialogIO, createMenuBar, createParameterTable, createProgramFrame, destroy, endHook, error, error, error, exit, fileExists, fileExists, fileExistsInsideJAR, fileExistsInsideJAR, fileExistsOnDisk, fileExistsOnDisk, fileSize, fileSize, focusGained, focusLost, getAnimationDelay, getAppletStub, getArgumentArray, getBoolean, getBoolean, getBoolean, getBorder, getBottomY, getCenterLocation, getCenterX, getCenterY, getCentralRegionSize, getConsole, getDialog, getDouble, getDouble, getDouble, getDouble, getHeight, getInputModel, getInteger, getInteger, getInteger, getInteger, getJFrame, getLayout, getLine, getLine, getMainThread, getMenuBar, getOutputColor, getOutputModel, getParameter, getParameterTable, getPreferredSize, getReader, getReal, getReal, getReal, getReal, getRegionPanel, getRightX, getScreenHeight, getScreenSize, getScreenWidth, getStartupObject, getTitle, getWidth, getWindow, getWriter, getYesOrNo, hasConfiguration, init, insertUpdate, intervalAdded, intervalRemoved, isAnimated, isApplet, isAppletMode, isExitOnClose, isInitialized, itemStateChanged, keyPressed, keyReleased, keyTyped, killMe, loadConfiguration, main, menuCanceled, menuDeselected, menuSelected, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, openFile, openFile, openFileFromDisk, openFileFromDisk, openFileFromJAR, openFileFromJAR, pack, pause, pauseTick, popupMenuCanceled, popupMenuWillBecomeInvisible, popupMenuWillBecomeVisible, print, print, print, print, print, print, print, print, print, print, print, print, print, print, print, print, printf, println, println, println, println, println, println, println, println, println, println, println, println, println, println, println, println, println, prompt, readBoolean, readBoolean, readBoolean, readDouble, readDouble, readDouble, readDouble, readInt, readInt, readInt, readInt, readLine, readLine, remove, remove, removeAll, removeFromRegion, removeMenuBar, removeUpdate, repaint, run, runHook, saveConfiguration, setAnimated, setAnimationDelay, setAppletStub, setBackground, setBottomY, setCenterLocation, setCenterX, setCenterY, setConsole, setDialog, setExitOnClose, setFramesPerSecond, setHeight, setInputModel, setInvisible, setJFrame, setJMenuBar, setLayout, setLocation, setLocation, setOutputColor, setOutputModel, setParameter, setParameterTable, setPauseScaleFactor, setResizable, setRightX, setShowPixelGrid, setShowPixelInfo, setSize, setStartupObject, setTitle, setWidth, setX, setY, showErrorMessage, start, start, startAnimation, startHook, stateChanged, stopAnimation, textValueChanged, validate, valueChanged, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowGainedFocus, windowIconified, windowLostFocus, windowOpened, windowStateChangedcreateRootPane, getAccessibleContext, getContentPane, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isRootPaneCheckingEnabled, paramString, repaint, setContentPane, setGlassPane, setLayeredPane, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, updategetAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameterInfo, isActive, isValidateRoot, newAudioClip, play, play, resize, resize, setStub, showStatus, stopadd, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getListeners, getMaximumSize, getMinimumSize, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validateTreeaction, 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, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, revalidate, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic static final String WORLDS_DIRECTORY
public static final String WORLD_EXTENSION
public static final int NORTH
public static final int EAST
public static final int SOUTH
public static final int WEST
public static final int INFINITE
public static final int SIMPLE
public static final int FANCY
public static final Color BLACK
public static final Color BLUE
public static final Color CYAN
public static final Color DARK_GRAY
public static final Color GRAY
public static final Color GREEN
public static final Color LIGHT_GRAY
public static final Color MAGENTA
public static final Color ORANGE
public static final Color PINK
public static final Color RED
public static final Color WHITE
public static final Color YELLOW
public Event<KarelProgram.State> StateEvent
public void main()
KarelProgram class, you need to
override the definition of main so that it contains the code
for your application.public void setStatus(String status)
public KarelWorld getWorld()
KarelWorld object in which Karel lives.KarelWorld object in which Karel livesprotected void setWorld(KarelWorld world)
public static String getWorldDirectory()
protected KarelWorld createWorld()
KarelWorld in which Karel lives. Subclasses can
override this method to create their own KarelWorld types.World object in which Karel livesprotected boolean isStarted()
protected Karel getKarel()
public void add(Karel karel)
public void add(KarelInterface karel, int x, int y, int dir, int nBeepers)
public boolean menuAction(ActionEvent event)
ProgrammenuAction in class Programprotected void loadConfiguration(Properties props)
ProgramloadConfiguration in class Programprops - properties to load fromprotected void saveConfiguration(Properties props)
ProgramsaveConfiguration in class Programpublic void loadInitialWorld()