资源简介
模拟首次适应法动态分区存储管理 java实现的小程序
代码片段和文件信息
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class OS4 extends Jframe
{
ScrollPane sp;
JTextArea ta;
JTextField tf1tf2tf3tf4tf5;
GridLayout gl1gl2gl3gl4;
JLabel l1l2l3l4l5;
JButton jb1jb2jb3jb4jb5;
JPanel p1p2p3p4;
Vector rf;
process p;
process q;
public OS4()
{
super(“首次适应法动态分区存储管理“);
rf=new Vector();
Container container=this.getContentPane();
sp=new ScrollPane(0);
ta=new JTextArea(200200);
tf1=new JTextField(“空闲“);
tf2=new JTextField(“0“);
tf3=new JTextField(“0“);
tf3.setEnabled(false);
tf4=new JTextField(“0“);
tf5=new JTextField(““);
gl2=new GridLayout(3255);
gl3=new GridLayout(1350);
gl4=new GridLayout(2355);
l1=new JLabel(“请输入进程名:“);
l2=new JLabel(“请输入申请空间大小:“);
l3=new JLabel(“首地址:“);
l4=new JLabel(“申请空间大小:“);
l5=new JLabel(“释放进程名:“);
jb1=new JButton(“空闲“);
jb1.addActionListener(new Bt());
jb2=new JButton(“申请“);
jb2.addActionListener(new Bt());
jb5=new JButton(“提交“);
jb5.addActionListener(new Bt());
jb3=new JButton(“提交“);
jb3.addActionListener(new Bt());
jb4=new JButton(“提交“);
jb4.addActionListener(new Bt());
p1=new JPanel();
p2=new JPanel();
p3=new JPanel();
p4=new JPanel();
p2.setLayout(gl2);
p2.add(l1);
p2.add(tf1);
p2.add(l2);
p2.add(tf2);
p2.add(l3);
p2.add(tf3);
p2.setBounds(1010270100);
p3.setLayout(gl3);
p3.add(jb1);
p3.add(jb2);
p3.add(jb5);
p3.setBounds(1011527030);
sp.add(ta);
sp.setBounds(10150270235);
p4.setLayout(gl4);
p4.add(l4);
p4.add(tf4);
p4.add(jb3);
p4.add(l5);
p4.add(tf5);
p4.add(jb4);
p4.setBounds(1039027070);
container.setLayout(null);
container.add(p1);
container.add(p2);
container.add(p3);
container.add(p4);
container.add(sp);
setResizable(false);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e1)
{
System.exit(0);
}
});
setBounds(5050300500);
setVisible(true);
}
public void output()
{
ta.append(“空闲块\n“);
ta.append(“首地址\t大小\n“);
for(int i=0;i {
if(((process)rf.elementAt(i)).name==““)
{
ta.append(Integer.toString(((process)rf.elementAt(i)).address));
ta.append(“\t“);
ta.append(Integer.toString(((process)rf.elementAt(i)).data));
ta.append(“\n“);
}
}
ta.append(“\n“);
ta.append(“分配块\n“);
ta.append(“进程名\t首地址\t大小\n“);
for(int i=0;i {
if(((process)rf.elementAt(i)).name!=““)
{
ta.append(((process)rf.elementAt(i)).name);
ta.append(“\t“);
ta.append(Integer.toString(((process)rf.elementAt(i)).address));
ta.append(“\t“);
ta.append(Integer.toString(((process)rf.elementAt(i)).data));
ta.append(“\n“);
}
}
ta.append(“\n“);
}
class Bt implements ActionListener
{
public void actionPerformed(ActionEvent e2)
{
- 上一篇:逆波兰式的生成
- 下一篇:二期结业项目易买网购物车
评论
共有 条评论