elevatorcasestudy.java
来自「JAVA 多线程不可多得的好例子」· Java 代码 · 共 54 行
JAVA
54 行
// ElevatorCaseStudy.java
// Application with Elevator Model, View, and Controller (MVC)
package com.deitel.jhtp5.elevator;
// Java core packages
import java.awt.*;
// Java extension packages
import javax.swing.*;
// Deitel packages
import com.deitel.jhtp5.elevator.model.*;
import com.deitel.jhtp5.elevator.view.*;
import com.deitel.jhtp5.elevator.controller.*;
public class ElevatorCaseStudy extends JFrame {
// model, view and controller
private ElevatorSimulation model;
private ElevatorView view;
private ElevatorController controller;
// constructor instantiates model, view, and controller
public ElevatorCaseStudy()
{
super( "Deitel Elevator Simulation" );
// instantiate model, view and ,controller
model = new ElevatorSimulation();
view = new ElevatorView();
controller = new ElevatorController( model );
// register View for Model events
model.setElevatorSimulationListener( view );
// add view and controller to ElevatorSimulation
getContentPane().add( view, BorderLayout.CENTER );
getContentPane().add( controller, BorderLayout.SOUTH );
} // end ElevatorSimulation constructor
// main method starts program
public static void main( String args[] )
{
// instantiate ElevatorSimulation
ElevatorCaseStudy caseStudy = new ElevatorCaseStudy();
caseStudy.setDefaultCloseOperation( EXIT_ON_CLOSE );
caseStudy.pack();
caseStudy.setVisible( true );
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?