資源簡介
操作系統課設-頁面置換算法,實現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? 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\Animationfr
?????文件???????18997??2018-06-04?21:51??gui\Arithmetic.java
?????文件????????3510??2018-06-03?16:05??gui\Initfr
?????文件?????????851??2018-06-04?11:45??gui\TestOne.java
?????文件????????2878??2018-06-04?21:24??utils\ListUtils.java
評論
共有 條評論