// @topic S-0303-03-02-03 Java MVC Architecture Demo 3 // @brief The use case controller class package radio_button_test; public class ControllerDemo { //------------------------------ // data //------------------------------ private FrmDemo window; private ElevatorBank elevatorBank; //------------------------------ // constructors //------------------------------ public ControllerDemo() { elevatorBank = new ElevatorBank( 4/*debug number of floors*/ ); }//ControllerDemo //------------------------------ // operations //------------------------------ public void startAnimation() { // create and start new thread: ThreadAnimation thp = new ThreadAnimation( this ); Thread th = new Thread( thp ); th.start(); // invokes ThreadAnimation.run() on a new thread }//startAnimation public void animate() { // window.animate(); *** this is incorrect use of swing library! // we have to switch to EDT thread before we can "talk" to the window: java.awt.EventQueue.invokeLater( new Runnable() { public void run() { window.animate(); } } ); }//animate public FrmDemo getWindow() { return window; }//getWindow public void setWindow(FrmDemo window) { this.window = window; } public ElevatorBank getElevatorBank() { return elevatorBank; }//setWindow public void setElevatorBank(ElevatorBank elevatorBank) { this.elevatorBank = elevatorBank; }//setElevatorBank }//class ControllerDemo