⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mosmain.java

📁 一个用JAVA语言编写的MOS多道程序操作系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		this.jobnum_label.setFont(this.f2);
	    this.jobnum_label.setForeground(Color.RED);
	    this.job_num_label = new JLabel("当前用户作业总数:");
	    this.job_num_label.setFont(this.f3);
	    this.job_num_label.setForeground(Color.BLUE);
		this.barname_panel = new JPanel();
		this.barname_panel.setBackground(new Color(245,245,220));
		this.barname_panel.setBorder(BorderFactory.createTitledBorder(edge1,
	    		"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
		this.barname_panel.setLayout(new GridLayout(4,1));
		this.barname_panel.add(this.job_num_label);
		this.barname_panel.add(this.jl_progress[0]);
		this.barname_panel.add(this.jl_progress[1]);
		this.barname_panel.add(this.jl_progress[2]);
		pro_table = new int[3];
		var.pro_table = this.pro_table;
		
		//初始化进度条
		jpb_progress = new JProgressBar[3];
		var.jpb_progress = this.jpb_progress;
		jpb_progress[0] = new JProgressBar(0,1);
		this.jpb_progress[0].setFont(this.f_job);
	    this.jpb_progress[0].setForeground(new Color(0,0,204));
		jpb_progress[0].setBorder(BorderFactory.createTitledBorder(edge2,
	    		"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
		jpb_progress[1] = new JProgressBar(0,1);
		this.jpb_progress[1].setFont(this.f_job);
	    this.jpb_progress[1].setForeground(new Color(0,0,204));
		jpb_progress[1].setBorder(BorderFactory.createTitledBorder(edge2,
	    		"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
		jpb_progress[2] = new JProgressBar(0,1);
		this.jpb_progress[2].setFont(this.f_job);
	    this.jpb_progress[2].setForeground(new Color(0,0,204));
		jpb_progress[2].setBorder(BorderFactory.createTitledBorder(edge2,
	    		"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
//		设置进度条
		for(int i = 0;i < jpb_progress.length;i++)
		{jpb_progress[i].setBorder(edge2);jpb_progress[i].setStringPainted(true);}
		
		this.barvalue_panel = new JPanel();
		this.barvalue_panel.setBackground(new Color(250,246,215));
		this.barvalue_panel.setLayout(new GridLayout(4,2));
		this.barvalue_panel.setBorder(BorderFactory.createTitledBorder(edge1,
	    		"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
		this.barvalue_panel.add(this.jobnum_label);
		this.barvalue_panel.add(this.jpb_progress[0]);
		this.barvalue_panel.add(this.jpb_progress[1]);
		this.barvalue_panel.add(this.jpb_progress[2]);
//	    create queue panel;
	    f = new Font("SansSerif",Font.ROMAN_BASELINE,18);	
	    this.queue_panel = new JPanel();
	    this.queue_panel.setBackground(new Color(255,228,196));
	    this.queue_panel.setLayout(new BorderLayout());
	    this.queue_panel.setBorder(BorderFactory.createTitledBorder(edge1,
	    		"作业进度条",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
	    this.queue_panel.add(this.barname_panel,BorderLayout.WEST);
	    this.queue_panel.add(this.barvalue_panel,BorderLayout.CENTER);
	    
//	    create cpu state panel;
	    this.cpu_label = new JLabel("  cpu label",JLabel.CENTER);
	    this.cpu_label.setFont(f2);
	    this.cpu_label.setForeground(Color.BLUE);
	    this.var_cpu_label = new JLabel("   NULL",JLabel.CENTER);
	    var.var_cpu_label = this.var_cpu_label;
	    this.var_cpu_label.setFont(f2);
	    this.var_cpu_label.setForeground(new Color(220,20,60));
	    this.cpu_box = Box.createVerticalBox();
	    this.cpu_box.setBorder(BorderFactory.createTitledBorder(edge1,
	    		"CPU",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
	    this.cpu_box.add(Box.createVerticalStrut(80));
//	    this.cpu_box.add(this.cpu_label);
//	    this.cpu_box.add(Box.createVerticalStrut(20));
	    this.cpu_box.add(this.var_cpu_label);
	    this.cpu_box.add(Box.createVerticalStrut(50));
	    
//	    create show_prt_sys panel;
	    this.prt_area = new JTextArea();
	    var.prt_area = this.prt_area;
	    this.prt_area.setFont(f2);
	    this.prt_area.setForeground(new Color(47,79,79));
	    this.prt_area.setEditable(false);
	    this.prt_area.setBackground(Color.WHITE);	 

	    this.prt_label = new JLabel("print area",JLabel.RIGHT);
	    this.prt_label.setForeground(Color.BLUE);
	    this.prt_label.setBackground(Color.orange);
	    this.prt_label.setFont(f);
	    this.chan1_label = new JLabel("通道1:");
	    this.chan1_label.setHorizontalAlignment(JLabel.RIGHT);
	    this.chan1_label.setForeground(Color.BLUE);
	    this.chan1_label.setBackground(Color.orange);
	    this.chan1_label.setFont(f);
	    this.chan2_label = new JLabel("通道2:",JLabel.RIGHT);
	    this.chan2_label.setForeground(Color.BLUE);
	    this.chan2_label.setBackground(Color.orange);
	    this.chan2_label.setFont(f);
	    this.chan3_label = new JLabel("通道3:",JLabel.RIGHT);
	    this.chan3_label.setForeground(Color.BLUE);
	    this.chan3_label.setBackground(Color.orange);
	    this.chan3_label.setFont(f);
	    this.chan_box = Box.createVerticalBox();
	    this.chan_box.add(this.chan1_label);
	    this.chan_box.add(Box.createVerticalStrut(25));
	    this.chan_box.add(this.chan2_label);
	    this.chan_box.add(Box.createVerticalStrut(25));
	    this.chan_box.add(this.chan3_label);
	    this.chan_box.add(Box.createVerticalStrut(25));
	    this.var_chan1_label = new JLabel("闲",JLabel.LEFT);
	    this.var_chan1_label.setForeground(Color.RED);
	    this.var_chan1_label.setBackground(Color.orange);
	    this.var_chan1_label.setFont(f2);
	    this.var_chan2_label = new JLabel("闲",JLabel.LEFT);
	    this.var_chan2_label.setForeground(Color.RED);
	    this.var_chan2_label.setBackground(Color.orange);
	    this.var_chan2_label.setFont(f2);
	    this.var_chan3_label = new JLabel("闲",JLabel.LEFT);
	    this.var_chan3_label.setForeground(Color.RED);
	    this.var_chan3_label.setBackground(Color.orange);
	    this.var_chan3_label.setFont(f2);
	    this.var_chan_box = Box.createVerticalBox();
	    this.var_chan_box.add(this.var_chan1_label);
	    this.var_chan_box.add(Box.createVerticalStrut(25));
	    this.var_chan_box.add(this.var_chan2_label);
	    this.var_chan_box.add(Box.createVerticalStrut(25));
	    this.var_chan_box.add(this.var_chan3_label);
	    this.var_chan_box.add(Box.createVerticalStrut(25));
	    this.tot_chan_box = Box.createHorizontalBox();
	    this.tot_chan_box.setBorder(BorderFactory.createTitledBorder(edge1,
	    		"通道状态",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
	    this.tot_chan_box.add(Box.createHorizontalStrut(35));
	    this.tot_chan_box.add(this.chan_box);
	    this.tot_chan_box.add(this.var_chan_box);
	    this.tot_chan_box.add(Box.createHorizontalStrut(35));
	    this.prt_box = Box.createHorizontalBox();
		this.prt_box.setBackground(new Color(100,149,237));
	    this.prt_box.setBorder(BorderFactory.createTitledBorder(edge1,
	    		"打印信息",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
	    this.prt_scr_pane = new JScrollPane(this.prt_area);
	    this.prt_box.add(this.prt_scr_pane);
	    this.chan_prt_box = Box.createHorizontalBox();
	    this.chan_prt_box.setBorder(BorderFactory.createTitledBorder(edge1,
	    		"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
//	    repair;
	    this.chan_prt_box.add(this.tot_chan_box);
	    this.chan_prt_box.add(this.prt_box);
	    this.chan_prt_box.add(Box.createHorizontalStrut(25));
	    
	    this.cpu_state_panel = new JPanel();
	    this.cpu_state_panel.setBackground(new Color(250,235,215));
	    this.cpu_state_panel.setLayout(new BorderLayout());
	    this.cpu_state_panel.setBorder(BorderFactory.createTitledBorder(edge1,
	    		"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
	    this.cpu_state_panel.add(this.cpu_box,BorderLayout.WEST);
	    this.cpu_state_panel.add(this.chan_prt_box,BorderLayout.CENTER);
	    
//	    create show_state panel;
	    this.show_stat_panel = new JPanel();
	    this.show_stat_panel.setLayout(new BorderLayout(40,20));
	    this.show_stat_panel.setBorder(BorderFactory.createTitledBorder(edge1,
	    		"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
	    this.show_stat_panel.add(this.queue_panel,BorderLayout.NORTH);
	    this.show_stat_panel.add(this.cpu_state_panel,BorderLayout.CENTER);

		
//	    add panel to collect_panel;
	    this.collect_panel = new JPanel();
	    this.collect_panel.setBackground(new Color(250,250,210));
	    this.collect_panel.setLayout(new BorderLayout(20,10));
	    this.collect_panel.setBorder(BorderFactory.createTitledBorder(edge2,
	    		"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,f3));
	    this.collect_panel.add(this.tot_inpu_panel,BorderLayout.NORTH);
	    this.collect_panel.add(this.show_stat_panel,BorderLayout.CENTER);
	    this.collect_panel.add(this.show_prtsys_box,BorderLayout.SOUTH);
	    this.collect_panel.add(this.show_mmdisk_box,BorderLayout.EAST);
	    con.add(this.collect_panel);
	    var.setMain(this);
	    
		que_pcb_wait.add(new MosPCB((byte)(1),FinalVar.CPUMODE_SYS,
				null,FinalVar.PCB_BLOCK));
		que_pcb_wait.add(new MosPCB((byte)(2),FinalVar.CPUMODE_SYS,
				null,FinalVar.PCB_BLOCK));
		que_pcb_wait.add(new MosPCB((byte)(3),FinalVar.CPUMODE_SYS,
				null,FinalVar.PCB_BLOCK));
		proc = new MosProcess(mm, cpu, rom, var, que_jcb_finish, que_pcb_ready, disk,chan1,chan2,	
				chan3, que_pcb_wait, que_jcb_ready, que_jcb_start,p1,p2,p3);
		proc.processStart();
		
	    con.validate();
	    
	    setTitle("用户登录");
	    setSize(dim.width,dim.height - 30);
	    
	    new ImageTest(var);
	    mosp = new MosPrt();
	    this.kbinb = new KBInBuffer();
	    this.prtoutb = new PrtOutBuffer();
	    
//	    根据参数 b 的值显示或隐藏此组件;
	    setVisible(true);
	    
//	    可否由用户调整窗口大小;
	    setResizable(false);
//	    设置窗口图标;		
	    Image myimage = tool.getImage("11.gif");
	    setIconImage(myimage);
	    setTitle("MOS多道批处理系统");
	    addWindowListener(new WindowAdapter() {
	      public void windowClosing(WindowEvent e) {
	    	  mosp.var_out_label[0].setText("" + var.getTime());
	    	  mosp.var_out_label[1].setText("" + var.getAvgTime());
	    	  mosp.setVisible(true);
	      }
	    });
		
	}
	
	void proMalloc(int id,String name,int haddr)
	{
		for(int i = 0;i < pro_table.length;i++)
		{
			if(pro_table[i] == 0)
			{
				pro_table[i] = id;
				jl_progress[i].setText(name);
				jpb_progress[i].setMaximum(haddr);
				break;
			}
		}
	}
	
	void proMsg(int id,int value)
	{
		for(int i = 0;i < pro_table.length;i++)
		{
			if(pro_table[i] == id)
			{
				if(value > jpb_progress[i].getValue())jpb_progress[i].setValue(value);
			}
		}
	}
	
	void proFree(int id)
	{
		for(int i = 0;i < pro_table.length;i++)
		{
			if(pro_table[i] == id)
			{
				pro_table[i] = 0;
				jl_progress[i].setText("None");
				jpb_progress[i].setValue(0);
			}
		}
	}
	
	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource() == this.input_btn) {
			this.input_btn.setEnabled(false);
			cpu.setIOI((byte)1);
		}
		else if(e.getSource() == this.kb_btn) {
			this.kbinb.setVisible(true);
		}
		else if(e.getSource() == this.prt_btn) {
			this.prtoutb.setVisible(true);
		}
		else if(e.getSource() == this.stop_btn) {
			var.st_nx_switch = 2;
			this.stop_btn.setEnabled(false);
			this.next_btn.setEnabled(true);
			this.contin_btn.setEnabled(true);
		}
		else if(e.getSource() == this.next_btn) {
			var.st_nx_switch = 1;
		}
		else if(e.getSource() == this.contin_btn) {
			var.st_nx_switch = 0;
			this.stop_btn.setEnabled(true);
			this.next_btn.setEnabled(false);
			this.contin_btn.setEnabled(false);
		}
	}
	public static void main(String[] args) {
		// TODO 自动生成方法存根
		new MosMain();
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -