📄 processmanager.java
字号:
if(!v4.isEmpty()){
if(!v2.isEmpty()){
v4.add(v2.remove(0));
}
v2.add(0,v4.remove(0));
numberupdata();
areaupdata();
listupdata();
}
else{JOptionPane.showMessageDialog(this,"No Process is Executing!","message",JOptionPane.ERROR_MESSAGE );
areaupdata();
}
}
else if(field.getText().compareTo("b")==0){
add1=0;
if(!v4.isEmpty()){
v3.add(0,v4.remove(0));
if(!v2.isEmpty()){
v4.add(v2.remove(0));
}
numberupdata();
areaupdata();
listupdata();
}
else{JOptionPane.showMessageDialog(this,"No Process is Executing!","message",JOptionPane.ERROR_MESSAGE );
areaupdata();
}
}
else if(field.getText().compareTo("w")==0){
add1=0;
if(!v3.isEmpty()){
v2.add(0,v3.remove(0));
if(v4.isEmpty()){
if(!v2.isEmpty()){
v4.add(v2.remove(0));
}
}
numberupdata();
areaupdata();
listupdata();
}
else{JOptionPane.showMessageDialog(this,"No Process is Blocked!","message",JOptionPane.ERROR_MESSAGE );
areaupdata();
}
}
else if(field.getText().compareTo("e")==0){
add1=0;
if(!v4.isEmpty()){
v4.remove(0);
v1.add("Blank PCB");
if(!v2.isEmpty()){
v4.add(v2.remove(0));
}
numberupdata();
areaupdata();
listupdata();
}
else{JOptionPane.showMessageDialog(this,"No Process is Executing!","message",JOptionPane.ERROR_MESSAGE );
areaupdata();
}
}
else{if(inputname==0){
JOptionPane.showMessageDialog(this,"Error Command!","message",JOptionPane.ERROR_MESSAGE );
areaupdata();
System.out.println("nei");
}
}
}
else{JOptionPane.showMessageDialog(this,"Error Command!","message",JOptionPane.ERROR_MESSAGE );
areaupdata();
System.out.println("sdfsdfdsfs");
}
}
public void listupdata(){
list1.setListData(v1);
list2.setListData(v2);
list3.setListData(v3);
list4.setListData(v4);
}
public void areaupdata(){
if(field.getText().length()!=0)
area.append("\n>"+field.getText());
field.setText("");
}
public void numberupdata(){
pA.setBorder(new TitledBorder(new LineBorder(Color.gray,2),"BLANK"+" "+v1.size()));
pB.setBorder(new TitledBorder(new LineBorder(Color.gray,2),"READY"+" "+v2.size()));
pC.setBorder(new TitledBorder(new LineBorder(Color.gray,2),"BLOCK"+" "+v3.size()));
pD.setBorder(new TitledBorder(new LineBorder(Color.gray,2),"EXECUTE"+" "+v4.size()));
}
public void init(){
v1.clear();
for(int i=0;i<10;i++){
v1.add("Blank PCB");
}
v2.clear();
v3.clear();
v4.clear();
listupdata();
numberupdata();
area.setText(a);
field.setText("");
}
public void add(){
if(field.getText().length()!=0){
v2.add(0,field.getText());areaupdata();listupdata();numberupdata();inputname=0;
if(v4.isEmpty()){
v4.add(v2.remove(0));
listupdata();
numberupdata();
}
}
}
public void creat(){
areaupdata();
if(!v1.isEmpty()){
inputname=1;
String j=JOptionPane.showInputDialog(this,"In put the name:","Input",JOptionPane.OK_CANCEL_OPTION);
if(j.length()!=0){
v1.remove(0);
Vector v=new Vector();
Date date=new Date();
String temp=date.toString();
Random r=new Random();
v.add(j);
v.add(temp.substring(14,temp.indexOf('C')));
v.add(r.nextInt(10));
v2.add(0,v);
areaupdata();listupdata();numberupdata();inputname=0;
/*if(v4.isEmpty()){
v4.add(v2.remove(0));
listupdata();
numberupdata();
}*/
}
}
else{JOptionPane.showMessageDialog(this,"There is no blank PCB!","message",JOptionPane.ERROR_MESSAGE );
areaupdata();
}
}
public void execute(){
aa.add(b7);
aa.add(b8);
aa.add(b9);
b7.addActionListener(this);
b8.addActionListener(this);
b9.addActionListener(this);
d.getContentPane().setLayout(new BorderLayout());
d.getContentPane().add(b7,BorderLayout.NORTH);
d.getContentPane().add(b8,BorderLayout.CENTER);
d.getContentPane().add(b9,BorderLayout.SOUTH);
d.pack();
d.setVisible(true);
if(v4.isEmpty()){
if(!v2.isEmpty()){
if(suanfa=="FIFS"){
v4.add(v2.remove(0));
areaupdata();listupdata();numberupdata();
}
else if(suanfa=="STF"){
int num=0;
for(int i=1;i<v2.size();i++){
Vector v11=(Vector)v2.elementAt(num);
Vector v22=(Vector)v2.elementAt(num);
if((Integer)v22.elementAt(2)<(Integer)v11.elementAt(2))
num=i;
}
v4.add(v2.remove(num));
}
numberupdata();
areaupdata();
listupdata();
}
else{JOptionPane.showMessageDialog(this,"There is no Ready Process!","message",JOptionPane.ERROR_MESSAGE );
areaupdata();
}
}
else{JOptionPane.showMessageDialog(this,"A Process is Executing!","message",JOptionPane.ERROR_MESSAGE );
areaupdata();
}
}
public void weak(){
if(!v3.isEmpty()){
v2.add(0,v3.remove(0));
if(v4.isEmpty()){
if(!v2.isEmpty()){
v4.add(v2.remove(0));
}
}
numberupdata();
areaupdata();
listupdata();
}
else{JOptionPane.showMessageDialog(this,"No Process is Blocked!","message",JOptionPane.ERROR_MESSAGE );
areaupdata();
}
}
public void block(){
if(!v4.isEmpty()){
v3.add(0,v4.remove(0));
if(!v2.isEmpty()){
v4.add(v2.remove(0));
}
numberupdata();
areaupdata();
listupdata();
}
else{JOptionPane.showMessageDialog(this,"No Process is Executing!","message",JOptionPane.ERROR_MESSAGE );
areaupdata();
}
}
public void exit(){
if(!v4.isEmpty()){
v4.remove(0);
v1.add("Blank PCB");
if(!v2.isEmpty()){
v4.add(v2.remove(0));
}
numberupdata();
areaupdata();
listupdata();
}
else{JOptionPane.showMessageDialog(this,"No Process is Executing!","message",JOptionPane.ERROR_MESSAGE );
areaupdata();
}
}
public void timeout(){
if(!v4.isEmpty()){
if(!v2.isEmpty()){
v4.add(v2.remove(0));
}
v2.add(0,v4.remove(0));
numberupdata();
areaupdata();
listupdata();
}
else{JOptionPane.showMessageDialog(this,"No Process is Executing!","message",JOptionPane.ERROR_MESSAGE );
areaupdata();
}
}
public static void main(String args[]){
ProcessManager t=new ProcessManager();
t.setSize(700,700);
t.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -