⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 emluatordemo.java

📁 高速公路客运仿真
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package Emluator;
import java.util.Vector;
import java.text.NumberFormat;
import javax.swing.*;
import java.awt.*;
import com.borland.jbcl.layout.*;
import javax.swing.border.*;
import java.awt.event.*;

/**
 * <p>Title: EmluatorDemo</p>
 * <p>Description: 仿真程序的演示,界面的实现</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: 西安电子科技大学计算机学院研03软件与理论</p>
 * @author 任声骏
 * @version 1.0
 */

public class EmluatorDemo extends JFrame implements Runnable{
  private int XN_V;//西安沃尔沃数量
  private int XN_I;//西安依维柯数量
  private int BJ_V;//宝鸡沃尔沃数量
  private int BJ_I;//宝鸡依维柯数量
  private int P_MAX;//每分钟到达的人数上限
  Emluator solve=null;//仿真逻辑类的对象,用于实现仿真的过程
  Thread emluator=null;//用线程emluator执行仿真,并触发界面的刷新
  int hour,minute;//hour表示当前小时数,minute表示当前分钟数
  int emluatorSpeed=1000;//仿真程序执行的速度
  JPanel jPanelImfo = new JPanel();
  XYLayout xYLayout1 = new XYLayout();
  XYLayout xYLayout2 = new XYLayout();
  JButton jButtonStart = new JButton();
  JButton jButtonStop = new JButton();
  JButton jButtonCancel = new JButton();
  JScrollPane jScrollPaneXN = new JScrollPane();
  JScrollPane jScrollPaneBJ = new JScrollPane();
  JTextArea jTextAreaXN = new JTextArea();
  JTextArea jTextAreaBJ = new JTextArea();
  JLabel jLabelXN = new JLabel();
  JLabel jLabelBJ = new JLabel();
  JComboBox jComboBoxCar = new JComboBox();
  JScrollPane jScrollPaneCar = new JScrollPane();
  JTextArea jTextAreaCar = new JTextArea();
  JPanel jPanelSet = new JPanel();
  XYLayout xYLayout3 = new XYLayout();
  JLabel jLabelXNV = new JLabel();
  JLabel jLabelXNI = new JLabel();
  JLabel jLabelBJV = new JLabel();
  JLabel jLabelBJI = new JLabel();
  JLabel jLabelPNM = new JLabel();
  JLabel jLabelSet = new JLabel();
  JLabel jLabelCar = new JLabel();
  JSpinner jSpinnerXNV = new JSpinner();
  JSpinner jSpinnerXNI = new JSpinner();
  JSpinner jSpinnerPNM = new JSpinner();
  JSpinner jSpinnerBJI = new JSpinner();
  JSpinner jSpinnerBJV = new JSpinner();
  JSpinner jSpinnerCarNum = new JSpinner();
  JLabel jLabelTime = new JLabel();
  JPanel jPanelDisplay = new DisplayPanel();
  JScrollPane jScrollPaneDisplay = new JScrollPane();
  XYLayout xYLayout4 = new XYLayout();
  JSlider jSliderSpeed = new JSlider();
  JLabel jLabelSpeed = new JLabel();
   public EmluatorDemo() {
     super("高速公路仿真");
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
   }
   public  static void main(String args[]){
     EmluatorDemo demo=new EmluatorDemo();
     demo.pack();
     demo.show();
   }
  private void jbInit() throws Exception {
    this.getContentPane().setLayout(xYLayout1);
    xYLayout1.setWidth(806);
    xYLayout1.setHeight(605);
    jPanelImfo.setEnabled(true);
    jPanelImfo.setBorder(BorderFactory.createEtchedBorder());
    jPanelImfo.setToolTipText("");
    jPanelImfo.setLayout(xYLayout2);
    jButtonStart.setFont(new java.awt.Font("Dialog", 0, 12));
    jButtonStart.setText("开始");
    jButtonStart.addActionListener(new EmluatorDemo_jButtonStart_actionAdapter(this));
    jButtonStop.setFont(new java.awt.Font("Dialog", 0, 12));
    jButtonStop.setForeground(Color.black);
    jButtonStop.setActionCommand("暂停");
    jButtonStop.setText("暂停");
    jButtonStop.addActionListener(new EmluatorDemo_jButtonStop_actionAdapter(this));
    jButtonCancel.setFont(new java.awt.Font("Dialog", 0, 12));
    jButtonCancel.setText("退出");
    jButtonCancel.addActionListener(new EmluatorDemo_jButtonCancel_actionAdapter(this));
    jLabelXN.setFont(new java.awt.Font("Dialog", 0, 12));
    jLabelXN.setText("西安站:");
    jLabelBJ.setFont(new java.awt.Font("Dialog", 0, 12));
    jLabelBJ.setText("宝鸡站:");
    jTextAreaBJ.setText("");
    jTextAreaXN.setText("");
    jTextAreaCar.setDoubleBuffered(false);
    jPanelSet.setLayout(xYLayout3);
    jLabelXNV.setFont(new java.awt.Font("Dialog", 0, 12));
    jLabelXNV.setText("西安沃尔沃:");
    jLabelXNI.setFont(new java.awt.Font("Dialog", 0, 12));
    jLabelXNI.setText("西安依维柯:");
    jLabelBJV.setFont(new java.awt.Font("Dialog", 0, 12));
    jLabelBJV.setText("宝鸡沃尔沃:");
    jLabelBJI.setFont(new java.awt.Font("Dialog", 0, 12));
    jLabelBJI.setText("宝鸡依维柯:");
    jLabelPNM.setFont(new java.awt.Font("Dialog", 0, 12));
    jLabelPNM.setMinimumSize(new Dimension(120, 18));
    jLabelPNM.setText("产生人数上限(/m):");
    jLabelSet.setFont(new java.awt.Font("Dialog", 0, 12));
    jLabelSet.setText("设置:");
    jLabelCar.setFont(new java.awt.Font("Dialog", 0, 12));
    jLabelCar.setText("车辆信息:");
    jSpinnerXNV.setValue(new Integer(5));
    jSpinnerXNV.setBorder(null);
    jSpinnerXNI.setBorder(null);
    jSpinnerXNI.setValue(new Integer(12));
    jSpinnerPNM.setBorder(null);
    jSpinnerPNM.setValue(new Integer(2));
    jSpinnerBJI.setBorder(null);
    jSpinnerBJI.setValue(new Integer(15));
    jSpinnerBJV.setBorder(null);
    jSpinnerBJV.setValue(new Integer(4));
    jComboBoxCar.addItem(new String("Volvo"));
    jComboBoxCar.addItem(new String("Iveco"));
    jLabelTime.setFont(new java.awt.Font("Monospaced", 0, 24));
    jLabelTime.setForeground(Color.black);
    jLabelTime.setText("7:30");
    jPanelSet.setBorder(BorderFactory.createEtchedBorder());
    jPanelDisplay.setLayout(xYLayout4);
    jLabelSpeed.setFont(new java.awt.Font("Dialog", 0, 12));
    jLabelSpeed.setText("调速:");
    jSliderSpeed.setMaximum(1000);
    jSliderSpeed.setMinimum(50);
    jSliderSpeed.setValue(1000);
    jPanelSet.add(jLabelXNV,  new XYConstraints(0, 0, -1, 29));
    jPanelSet.add(jSpinnerXNV,  new XYConstraints(6, 26, 72, -1));
    jPanelSet.add(jLabelXNI,  new XYConstraints(105, 0, -1, 24));
    jPanelSet.add(jLabelBJV,  new XYConstraints(209, 0, -1, 27));
    jPanelSet.add(jSpinnerBJV,  new XYConstraints(212, 26, 72, -1));
    jPanelSet.add(jSpinnerBJI,  new XYConstraints(307, 26, 72, -1));
    jPanelSet.add(jLabelBJI, new XYConstraints(305, 0, -1, 24));
    jPanelSet.add(jSpinnerXNI,  new XYConstraints(102, 26, 72, -1));
    jPanelSet.add(jSpinnerPNM, new XYConstraints(394, 26, 72, -1));
    jPanelSet.add(jLabelPNM,   new XYConstraints(393, 0, 110, 23));
    this.getContentPane().add(jLabelSet,  new XYConstraints(233, 4, 66, 26));
    this.getContentPane().add(jPanelSet,           new XYConstraints(12, 32, 513, 64));
    this.getContentPane().add(jPanelImfo,              new XYConstraints(3, 340, 800, 262));
    jPanelImfo.add(jScrollPaneCar,     new XYConstraints(515, 76, 273, 178));
    jPanelImfo.add(jLabelCar,   new XYConstraints(516, 46, 75, 21));
    jPanelImfo.add(jComboBoxCar,  new XYConstraints(602, 42, 81, 25));
    jPanelImfo.add(jSpinnerCarNum,  new XYConstraints(706, 42, 77, 25));
    jPanelImfo.add(jLabelXN,   new XYConstraints(1, 45, 59, 22));
    jPanelImfo.add(jLabelBJ, new XYConstraints(258, 46, 65, 21));
    jPanelImfo.add(jScrollPaneBJ, new XYConstraints(258, 78, 248, 176));
    jPanelImfo.add(jScrollPaneXN,  new XYConstraints(1, 78, 248, 176));
    jScrollPaneXN.getViewport().add(jTextAreaXN, null);
    jScrollPaneBJ.getViewport().add(jTextAreaBJ, null);
    jScrollPaneCar.getViewport().add(jTextAreaCar, null);
    this.getContentPane().add(jScrollPaneDisplay,        new XYConstraints(11, 110, 786, 228));
    this.getContentPane().add(jButtonStop, new XYConstraints(627, 22, 71, 26));
    this.getContentPane().add(jButtonStart, new XYConstraints(533, 22, 71, 26));
    this.getContentPane().add(jButtonCancel, new XYConstraints(722, 22, 71, 26));
    this.getContentPane().add(jLabelSpeed, new XYConstraints(533, 70, 46, 20));
    this.getContentPane().add(jSliderSpeed, new XYConstraints(593, 72, 187, 22));
    jScrollPaneDisplay.getViewport().add(jPanelDisplay, null);
    jPanelDisplay.add(jLabelTime,      new XYConstraints(352, 0, 90, 37));
  }
  //更新车站情况
  public void  refreshStationInfo(JTextArea station){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -