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

📄 carsimframe.java

📁 CarSim is an application for the simulating the (simplified) movement of cars on a two-dimensional s
💻 JAVA
字号:
package ope.carsim.gui;

import java.awt.Dimension;

import javax.swing.JLabel;
import javax.swing.JMenuItem;

import ope.carsim.Location;
import ope.guikka.ApplicationFrame;


/**
 * This class contains the user interface for the CarSim
 * program, which allows a the user to simulate simple car
 * behavior (driving, fueling).
 */
public class CarSimFrame extends ApplicationFrame {

  private JMenuItem quitItem;               // fixed value
  
  /**
   * Creates a CarSim application window. 
   */
  public CarSimFrame() {
  	this.setTitle("CarSim");

  	this.place(new JLabel("Double click to add car.  Drag a car with left mouse pressed to drive.  Right-click on a car to fuel."), 1, 1);
  	  	
  	CarMap map = new CarMap(new Location(-500, -500), new Location(500, 500));
  	map.setPreferredSize(new Dimension(1000, 600));
  	this.place(map, 2, 1);
  	
  	this.quitItem = new JMenuItem("Quit");
    this.place(this.quitItem, "Program");

  	this.pack();
  }

  
  /**
   * Event handler method: reacts to the selection of the 
   * "Quit" menu item by shutting down the application.
   * 
   * @param item the selected menu item
   */  
  public void menuItemSelected(JMenuItem item) {
    if (item == this.quitItem) {
      this.exit();
    } 
  }  
}

⌨️ 快捷键说明

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