您好,欢迎访问三七文档
当前位置:首页 > 金融/证券 > 金融资料 > 操作系统课程设计银行家算法和页面置换算法
南京工程学院操作系统课程设计说明书题目操作系统—银行家算法和页面置换算法班级软件101学生姓名刘洋学号202100320课设截图:源代码:3个类:MainFrame.java:importjava.awt.Font;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjavax.swing.ButtonGroup;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JPanel;importjavax.swing.JRadioButton;importjavax.swing.UIManager;importjavax.swing.UIManager.LookAndFeelInfo;publicclassMainFrameextendsJFrameimplementsActionListener{/****/privatestaticfinallongserialVersionUID=1L;privateJPanelpanel1,panel2,panel3;privateJLabellabel1,label2;privateJButtonbutton1;privateJRadioButtonb1,b2;publicMainFrame(){super(操作系统课程设计);this.setBounds(300,150,800,500);this.setBackground(java.awt.Color.LIGHT_GRAY);this.setLayout(newjava.awt.GridLayout(3,1));panel1=newJPanel();panel2=newJPanel();panel3=newJPanel();Fontf=newFont(楷体,1,60);Fontf1=newFont(宋体,3,30);Fontf2=newFont(幼圆,1,15);label1=newJLabel(操作系统课程设计);label1.setFont(f);label2=newJLabel(算法模拟题目:);label2.setFont(f1);panel1.add(label1);panel2.add(label2);ButtonGroupbgroup=newButtonGroup();b1=newJRadioButton(银行家算法,true);b1.setFont(f1);bgroup.add(b1);b2=newJRadioButton(页面置换算法);b2.setFont(f1);bgroup.add(b2);panel2.add(b1);panel2.add(b2);button1=newJButton(开始演示);button1.setFont(f2);button1.addActionListener(this);panel3.add(button1);this.add(panel1);this.add(panel2);this.add(panel3);this.setDefaultCloseOperation(EXIT_ON_CLOSE);this.setVisible(true);}publicvoidactionPerformed(ActionEvente){if(e.getSource()==button1){if(b1.isSelected()){newBanker();}if(b2.isSelected()){newYemian();}}}publicstaticvoidmain(String[]args){try{for(LookAndFeelInfoinfo:UIManager.getInstalledLookAndFeels()){if(Nimbus.equals(info.getName())){UIManager.setLookAndFeel(info.getClassName());break;}}}catch(Exceptione1){}newMainFrame();}}Banker.java:importjava.awt.*;importjava.awt.event.*;importjava.util.ArrayList;importjavax.swing.*;importjavax.swing.table.DefaultTableCellRenderer;importjavax.swing.table.DefaultTableModel;publicclassBankerextendsJFrameimplementsActionListener{/****/privatestaticfinallongserialVersionUID=1L;privateJTabletable1,table2;privateJPanelp0,p1,p11,p12,p13,p14,p2,p3,p31,p32,p33,p34,p4,p5;privateJLabelt1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11;privateJButtonb1,b2,b3,b4,b5,b6;privateTextFieldtext01,text02,text03,text04,text05,text06;//编辑框privateJTextField[]text1,text2,text3,text4,text5;//进程组的数据DefaultTableModeltablemodel,tablemodel1;ArrayListIntegerlist;int[][]claim,allocation,need;int[]available;int[]request,temavail,release;boolean[]possible;intm,n,index=0;publicBanker(){super(银行家算法模拟);p0=newJPanel();p1=newJPanel();p11=newJPanel();p12=newJPanel();p13=newJPanel();p14=newJPanel();p2=newJPanel();p3=newJPanel();p31=newJPanel();p32=newJPanel();p33=newJPanel();p34=newJPanel();p4=newJPanel();p5=newJPanel();p0.setLayout(newGridLayout(5,1));p1.setLayout(newGridLayout(4,1));p3.setLayout(newGridLayout(4,1));p1.add(p11);p1.add(p12);p1.add(p13);p1.add(p14);p3.add(p31);p3.add(p32);p3.add(p33);p3.add(p34);p0.add(p1);p0.add(p2);p0.add(p3);p0.add(p4);p0.add(p5);t1=newJLabel(进程数);t2=newJLabel(资源数);t3=newJLabel(进程号);t4=newJLabel(已分配资资源:);t5=newJLabel(资源最大需求:);t6=newJLabel(可用资源:);t7=newJLabel(请求资源进程号);t8=newJLabel(请求资源为);t9=newJLabel(释放资源);t10=newJLabel(安全序列);t11=newJLabel(释放资源进程号);b1=newJButton(确定);b2=newJButton(添加);b3=newJButton(确定);b4=newJButton(请求);b5=newJButton(开始检测);b6=newJButton(释放);text1=newJTextField[6];text2=newJTextField[6];text3=newJTextField[6];text4=newJTextField[6];text5=newJTextField[6];for(inti=0;i5;i++){text1[i]=newJTextField(4);text2[i]=newJTextField(4);text3[i]=newJTextField(4);text4[i]=newJTextField(4);text5[i]=newJTextField(4);}text01=newTextField(4);text02=newTextField(4);text03=newTextField(4);text04=newTextField(4);text05=newTextField(4);text06=newTextField(20);String[]columnNames1={进程号,allocation,claim,need,available};tablemodel=newDefaultTableModel(columnNames1,0);table1=newJTable(tablemodel);table1.setPreferredScrollableViewportSize(newDimension(700,200));table1.setRowHeight(20);table1.doLayout();DefaultTableCellRendererr=newDefaultTableCellRenderer();r.setHorizontalAlignment(JLabel.CENTER);table1.setDefaultRenderer(Object.class,r);JScrollPanepane1=newJScrollPane(table1);p11.add(t1);p11.add(text01);p11.add(t2);p11.add(text02);p11.add(b1);p12.add(t3);p12.add(text03);p12.add(b2);p13.add(t4);for(inti=0;i5;i++)p13.add(text1[i]);p14.add(t5);for(inti=0;i5;i++)p14.add(text2[i]);p2.add(pane1);p31.add(t6);for(inti=0;i5;i++)p31.add(text3[i]);p31.add(b3);p32.add(t7);p32.add(text04);p32.add(t8);for(inti=0;i5;i++)p32.add(text4[i]);p32.add(b4);p33.add(t11);p33.add(text05);p33.add(t9);for(inti=0;i5;i++)p33.add(text5[i]);p33.add(b6);p34.add(b5);String[]columnNames2={进程号,currentavail,need,allocation,curr...+allo...,possible};tablemodel1=newDefaultTableModel(columnNames2,0);table2=newJTable(tablemodel1);table2.setPreferredScrollableViewportSize(newDimension(700,200));table2.setRowHeight(20);table2.doLayout();DefaultTableCellRendererr1=newDefaultTableCellRenderer(
本文标题:操作系统课程设计银行家算法和页面置换算法
链接地址:https://www.777doc.com/doc-243063 .html