All Packages Class Hierarchy This Package Previous Next Index
Class duckMachine.GUI.ControlPanel
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----duckMachine.GUI.ControlPanel
- public class ControlPanel
- extends Panel
- implements ActionListener
The panel that listens to commands, sends them to the machine, and
reports back any errors.
-
ControlPanel(MachineFrame)
- The panel is the equivalent of the textual shell.
-
actionPerformed(ActionEvent)
- The method is called when the Stop button is pushed.
-
endCommand()
-
-
reportError(String)
-
-
reportStatus(String)
-
-
startCommand(Runnable)
- The execution of commands is centralized here.
ControlPanel
public ControlPanel(MachineFrame mf)
- The panel is the equivalent of the textual shell. It listens to
commands using four buttons: load, step, run, and stop, runs them
and displays the results including any errors that might have happened.
The control panel needs access to the main machine frame because it
creates new frames for file dialogs that need to refer to their parent.
startCommand
public void startCommand(Runnable command)
- The execution of commands is centralized here. Every command runs
in a newly created thread so as not to block the GUI. However, we do
not allow several machine commands to run simultaneously, so we keep
a record of the currently running command. The new thread runs at a
low priority so that the GUI can kill it if requested to do so
by a click on the Stop button.
endCommand
public void endCommand()
reportStatus
public void reportStatus(String message)
reportError
public void reportError(String message)
actionPerformed
public void actionPerformed(ActionEvent evt)
- The method is called when the Stop button is pushed.
All Packages Class Hierarchy This Package Previous Next Index