Chapter 13 Graphical User (Web domain) Interface Components: Part 2
Saturday, May 5th, 2007Chapter 13 Graphical User Interface Components: Part 2 787 According to Fig. 13.20, ElevatorModel.javaand ElevatorView.javado not depend on each other they communicate through interface ElevatorModelListener, which implements all interfaces in the simulation. ElevatorView.javarealizes interface ElevatorModelListener, and ElevatorModel.javadepends on interface ElevatorModelListener. Figure 13.20 contains several stereotypes words placed in guillemets ( ) indicating an element s role. We mentioned the interface stereotype in Thinking About Objects Section 11.10. The compilation stereotype describes the dependency between ElevatorSimulation.class and ElevatorSimulation.java ElevatorSimulation.javacompiles to ElevatorSimulation.class. The executable stereotype specifies that a component is an application, and the file stereotype specifies that a component is a file containing source code for the executable. Implementation: ElevatorSimulation.java We use the component diagram of Fig. 13.20, the class diagram of Fig. 13.19 and the use- case diagram of Fig. 12.28 to implement ElevatorSimulation.java (Fig. 13.21). Lines 12 14 import packages model, viewand controlleras specified in Fig. 13.20. 1 // ElevatorSimulation.java 2 // Application with Elevator Model, View, and Controller (MVC) 3 package com.deitel.jhtp4.elevator; 4 5 // Java core packages 6 import java.awt.*; 7 8 // Java extension packages 9 import javax.swing.*; 10 11 // Deitel packages 12 import com.deitel.jhtp4.elevator.model.*; 13 import com.deitel.jhtp4.elevator.view.*; 14 import com.deitel.jhtp4.elevator.controller.*; 15 16 public class ElevatorSimulation extends JFrame { 17 18 // model, view and controller 19 private ElevatorModel model; 20 private ElevatorView view; 21 private ElevatorController controller; 22 23 // constructor instantiates model, view, and controller 24 public ElevatorSimulation() 25 { 26 super( “Deitel Elevator Simulation” ); 27 28 // instantiate model, view and controller 29 model = new ElevatorModel(); 30 view = new ElevatorView(); 31 controller = new ElevatorController( model ); Fig. 13.21 Class ElevatorSimulationis the application for the elevator simulation (part 1 of 2).
Note: If you are looking for reliable webhost to maintain and run your java application check Vision java hosting services