java实现进程调度页面置换算法,可视化 主窗口函数:
package main; import java.awt.*; import java.awt.event.*; import java.text.SimpleDateFormat; import java.util.Date; import javax.swing.*; import frame.MemoryFrame; import frame.ProcessFrame; public class MainFrame extends JFrame{ private static final long serialVersionUID=1L; public MainFrame(){ setResizable(false); setBounds(250,17,900,700); setTitle("OS-模拟"); setLayout(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar=new JMenuBar(); this.setJMenuBar(menuBar); menuBar.setBackground(Color.black); JMenu aaa = new JMenu(" "); menuBar.add(aaa); aaa.setEnabled(false); // 帮助信息 JMenu help = new JMenu(" 说明 "); String[] s = new String[] { "双击图标进入指定功能界面" }; for (int i = 0; i < 1; i ) { help.add(new JMenuItem(s[i])); } menuBar.add(help); //开发组 JMenu people = new JMenu(" 项目信息 "); String[] x = new String[] { "开发者:LuAo,PeiQianlong,ChenCong","开发日期:2020-3"}; for (int i = 0; i < 2; i ) { people.add(new JMenuItem(x[i])); } menuBar.add(people); //mail JMenu mail = new JMenu(" 欢迎交流 "); String[] z = new String[] { "邮箱:luaonb@hotmail.com" }; for (int i = 0; i < 1; i ) { mail.add(new JMenuItem(z[i])); } menuBar.add(mail); } public static void main(String[] args) { JFrame frame=new MainFrame(); String plaf="com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; try{ UIManager.setLookAndFeel(plaf); SwingUtilities.updateComponentTreeUI(frame); }catch(Exception e){ JOptionPane.showMessageDialog(null, e); } frame.setVisible(true); //图标 Toolkit tk=Toolkit.getDefaultToolkit(); Image image=tk.createImage("image/操作系统.png"); frame.setIconImage(image); //背景 ImageIcon img=new ImageIcon("image/背景.jpg");//设置的图片路径 JLabel imgLabel=new JLabel(img); frame.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE)); imgLabel.setBounds(0,0,img.getIconWidth(), img.getIconHeight()); JPanel jp = (JPanel)frame.getContentPane(); jp.setOpaque(false); //页面置换 JButton button2=new JButton(); button2.setBounds(20, 20, 50, 50); ImageIcon logo2=new ImageIcon("image/置换.png"); button2.setIcon(logo2); frame.add(button2); button2.setBackground(Color.black); JLabel lb2=new JLabel("页面置换"); lb2.setBounds(17, 74, 100, 20);; frame.add(lb2); frame.setLayout(null); lb2.setForeground(Color.white); lb2.setBackground(Color.white); lb2.setFont(new Font("宋体", Font.BOLD, 14)); button2.addMouseListener(new MouseListener(){ public void mouseClicked(MouseEvent e) { if(e.getClickCount() == 2) new MemoryFrame(); } @Override public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub }}); //进程图标 JButton button3=new JButton(); button3.setBounds(20, 130, 50, 50); ImageIcon logo3=new ImageIcon("image/调度.png"); button3.setIcon(logo3); frame.add(button3); button3.setBackground(Color.black); JLabel lb3=new JLabel("进程调度"); lb3.setBounds(17, 186, 100, 20);; frame.add(lb3); frame.setLayout(null); lb3.setForeground(Color.white); lb3.setBackground(Color.white); lb3.setFont(new Font("宋体", Font.BOLD, 14)); button3.addMouseListener(new MouseListener(){ public void mouseClicked(MouseEvent e) { if(e.getClickCount() == 2) new ProcessFrame(); } @Override public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub }}); }}
评论