资源简介
电梯调度算法是用来模拟进程管理。一般操作系统课上会需要,哈哈
代码片段和文件信息
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JButton;
import javax.swing.Jframe;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.border.MatteBorder;
import javax.swing.plaf.basic.BasicArrowButton;
/*
* Created on 2004-5-1
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
/**
* @author Administrator
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class Listframe extends Jframe implements Runnable
{
private static int floorNum = 20; //楼层数
private static int listNum = 5; //电梯数
private ListThread[] listThread; //对应电梯的线程数组
Container cp;
JPanel floorPanel = new JPanel(); //用来显示每一楼层的楼层号和上下键的面板
JButton[] floorButton; //楼层号
BasicArrowButton[] upButton; //向上键
BasicArrowButton[] downButton; //向下键
JButton dispUp dispDown dispFloor;
Color pressedUpDownColor = Color.RED;
Color unPressedUpDownColor = new Color(170 170 200);
int[] upState; //用来记录向上键的状态
int[] downState; //用来记录向下键的状态
private JMenuBar menuBar;
private JMenu menu;
private JMenuItem chooses[] = {
//new JMenuItem(“电梯数(N)“)
//new JMenuItem(“楼层数(N)“)
new JMenuItem(“退出(X)“)};
public Listframe()
{
cp = this.getContentPane();
cp.setLayout(new GridLayout(1 listNum + 1));
floorPanel.setLayout(new GridLayout(floorNum + 1 3));
floorPanel.setBorder(new MatteBorder(2 4 2 2 Color.yellow));
floorButton = new JButton[floorNum];
upButton = new BasicArrowButton[floorNum];
downButton = new BasicArrowButton[floorNum];
dispFloor = new JButton(“层“);
dispFloor.setEnabled(false);
dispUp = new JButton(“上“);
dispUp.setEnabled(false);
dispDown = new JButton(“下“);
dispDown.setEnabled(false);
floorPanel.add(dispFloor);
floorPanel.add(dispUp);
floorPanel.add(dispDown);
MouseListener upListener = new UpButtonAction(); //向上键的Listener
//设置属性
for (int i = floorButton.length - 1; i >= 0; i--)
{
floorButton[i] = new JButton(String.valueOf(i + 1));
floorButton[i].setForeground(Color.green);
floorButton[i].setForeground(Color.green);
floorButton[i].setFont(new Font(“Serif“ Font.BOLD 13));
floorButton[i].setEnabled(false);
upButton[i] = new BasicArrowButton(BasicArrowButton.NORTH);
upButton[i].addMouseListener(upListener);
upButton[i].setBackground(unPressedUpDownColor);
downButton[i] = new BasicArrowButton(BasicArrowButton.SOUTH);
downButton[i].addMouseListener(upListener)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 31744 2004-05-09 22:41 李秋军(010200)\电梯程序说明书.doc
文件 10211 2004-05-05 16:50 李秋军(010200)\可执行程序\List.jar
文件 7229 2004-05-05 16:52 李秋军(010200)\源代码\Listfr
文件 829 2004-05-05 16:52 李秋军(010200)\源代码\ListMain.java
文件 7038 2004-05-05 16:52 李秋军(010200)\源代码\ListThread.java
目录 0 2009-03-15 21:01 李秋军(010200)\可执行程序
目录 0 2009-03-15 21:01 李秋军(010200)\源代码
目录 0 2009-03-15 21:01 李秋军(010200)
----------- --------- ---------- ----- ----
57051 8
评论
共有 条评论