• 大小: 8KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-08
  • 语言: 其他
  • 标签: GUI  

资源简介

操作系统课设-页面置换算法,实现FIFO、LRU、Clock三种置换算法,通过GUI界面展示。

资源截图

代码片段和文件信息

package gui;

import javax.swing.Jframe;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


import javax.swing.JTextField;

import utils.ListUtils;

public class Animationframe extends Jframe {


private static final long serialVersionUID = 1L;

// 访问序列长度
private int count;
// 内存块数
private int memory;
// 数据
private object[][] data;
// 访问序列
private String[] accessSequence;

ClockThread clockThread;
// 内存块
private JTextField[] textField;
// 当前访问页面
JTextArea current;

public Animationframe(int memory String[] accessSequence object[][] data) {

count = accessSequence.length;
this.memory = memory;
this.data = data;
this.accessSequence = accessSequence;

Jframe animationframe = new Jframe();
animationframe.settitle(“页面置换算法动态演示“);
animationframe.setBounds(550 260 541 562);
animationframe.setDefaultCloseOperation(2);
animationframe.getContentPane().setLayout(null);

JPanel functionPanel = new JPanel();
functionPanel.setBackground(Color.WHITE);
functionPanel.setBounds(10 10 224 453);
animationframe.getContentPane().add(functionPanel);
functionPanel.setLayout(null);

JButton autoRun = new JButton(“运行“);
autoRun.setBounds(33 72 93 23);
functionPanel.add(autoRun);

JLabel lab1 = new JLabel(“当前访问页面:“);
lab1.setBounds(33 221 93 23);
functionPanel.add(lab1);

current = new JTextArea();
current.setBounds(136 221 63 24);
functionPanel.add(current);

JButton stop = new JButton(“停止“);
stop.setBounds(33 137 93 23);
functionPanel.add(stop);

JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(244 10 257 453);
animationframe.getContentPane().add(scrollPane);

JPanel showPanel = new JPanel();
showPanel.setBackground(Color.WHITE);
scrollPane.setViewportView(showPanel);
showPanel.setLayout(null);

textField = new JTextField[memory];


/*textField1 = new JTextField();
textField1.setBounds(80 167 86 37);
showPanel.add(textField1);*/
for(int i = 0; i < memory; i ++) {
JTextField text = new JTextField();
text.setBounds(80 108 + i * 59 86 37);
text.setText(““);
textField[i] = text;
showPanel.add(textField[i]);
}

animationframe.setVisible(true);

autoRun.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {

clockThread = new ClockThread(Animationframe.this);
clockThread.start();
}
});

stop.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
clockThread.exit = true;
}
});

}

// 当前计数
private int currentCount = 0;


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        4640  2018-06-04 21:57  gui\Animationframe.java
     文件       18997  2018-06-04 21:51  gui\Arithmetic.java
     文件        3510  2018-06-03 16:05  gui\Initframe.java
     文件         851  2018-06-04 11:45  gui\TestOne.java
     文件        2878  2018-06-04 21:24  utils\ListUtils.java

评论

共有 条评论