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.


Constructor Index

 o ControlPanel(MachineFrame)
The panel is the equivalent of the textual shell.

Method Index

 o actionPerformed(ActionEvent)
The method is called when the Stop button is pushed.
 o endCommand()
 o reportError(String)
 o reportStatus(String)
 o startCommand(Runnable)
The execution of commands is centralized here.

Constructors

 o 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.

Methods

 o 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.

 o endCommand
 public void endCommand()
 o reportStatus
 public void reportStatus(String message)
 o reportError
 public void reportError(String message)
 o 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