资源简介
操作系统多线程的作业,模拟多个电梯的调度机制。使用jdk11开发环境。
代码片段和文件信息
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;
public class Listframe extends Jframe implements Runnable
{
private static int floorNum = 20; //楼层数
private static int elevatorNum = 5; //电梯数
private SubThread[] subThread;
//region UI设计___________________________________________
Container cp;
JPanel floorPanel;
JButton[] floorButton;
BasicArrowButton[] upButton;
BasicArrowButton[] downButton;
JButton dispUp dispDown dispFloor;
JMenuBar menuBar;
JMenu menu;
JMenuItem chooses[] = {
//new JMenuItem(“电梯数(N)“)
//new JMenuItem(“楼层数(N)“)
new JMenuItem(“退出(X)“)};
Color pressDownColor = Color.RED;
Color unPressDownColor = Color.GRAY;
int[] upState;
int[] downState;
//#endregion______________________________________________
public Listframe()
{
cp = this.getContentPane();
cp.setLayout(new GridLayout(1 elevatorNum + 1));
//region floorPanel_________________________________________________
floorPanel = new JPanel();
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 Listener = new ButtonAction();
for (int i = floorButton.length - 1; i >= 0; i--)
{
floorButton[i] = new JButton(String.valueOf(i + 1));
floorButton[i].setFont(new Font(“Serif“ Font.BOLD 13));
floorButton[i].setEnabled(false);
upButton[i] = new BasicArrowButton(BasicArrowButton.NORTH);
upButton[i].addMouseListener(Listener);
upButton[i].setBackground(unPressDownColor);
downButton[i] = new BasicArrowButton(BasicArrowButton.SOUTH);
downButton[i].addMouseListener(Listener);
downButton[i].setBackground(unPressDownColor);
floorPanel.add(floorButton[i]);
floorPanel.add(upButton[i]);
floorPanel.add(downButton[i]);
}
cp.add(floorPanel);
//endregion___________________________________________________________
//region menuBar______________________________________________________
menuBa
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6246 2019-05-06 23:01 Listfr
文件 842 2019-05-06 21:56 ListMain.java
文件 6842 2019-05-06 23:01 SubThread.java
----------- --------- ---------- ----- ----
13930 3
相关资源
- 图像隐写F5 JAVA源代码
- Java进阶教程-动力节点.txt
- 计算机组成原理(BOOTH算法)java源代
- SparkSQL HDFS JAVA调用完整
- jar包反编译工具java
- JSP读取TXT文件并显示
- 图形界面通讯录信息资料可用文本保
- 管道过滤器的实现java
- javax.servlet.rar
- java 我行我素购物管理系统源码
- JSP+JavaBean+Servlet实现分页技术
- JAVA的小赛车程序
- 剑指Java面试-Offer直通车.txt
- (java).doc
- Java读取json文件并对json数据进行读取
- Compiler_mean3.rar
- Delphi与JAVA互加解密AES算法
- java面试题 IBM交通银行等一些外包的
- 小区物业管理系统JAVA+sqlserver
- Java泛型三篇文章,让你彻底理解泛型
- 用Java程序编写一个记事本程序的设计
- 把java项目安装为window服务
- 基于JavaSocket多客户端并发通信聊天程
- 五子棋(java)
- java程序设计实用教程_(第3版)_课后
- java实现分治法寻找最近点对
- java网上oa办公系统原码
- Java生成二维码
- jstl_standard的jar包
- 纯JAVA不用数据库的,用数组对数据增
评论
共有 条评论