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

📄 mainapplet.java

📁 进程调度模拟程序
💻 JAVA
字号:
package dispatcher;import java.awt.*;import java.awt.event.*;import java.applet.*;import javax.swing.*;import javax.swing.border.*;import javax.swing.UIManager;public class MainApplet extends Applet {  private BorderLayout borderLayout1 = new BorderLayout();  String name[]={"A","B","C","D","E"};  String a[][]={{"0","2","4","6","8"},{"3","6","4","5","2"}};//new String[2][5];  int n[][]=new int[2][5];  private JScrollPane jScrollPane1 = new JScrollPane();  private JTable jTable1;  private BorderLayout borderLayout2 = new BorderLayout();  private JPanel jPanel1 = new JPanel();  private BorderLayout borderLayout3 = new BorderLayout();  private Border border1;  private JPanel jPanel2 = new JPanel();  private JButton jButton1 = new JButton();  private JLabel jLabel1 = new JLabel();  private GridBagLayout gridBagLayout1 = new GridBagLayout();  private JLabel jLabel3 = new JLabel();  private JLabel jLabel4 = new JLabel();  private JLabel jLabel2 = new JLabel();  public MainApplet() {    try{      UIManager.setLookAndFeel(          UIManager.getCrossPlatformLookAndFeelClassName());    }catch(Exception e){};  }  public void init() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  private void jbInit() throws Exception {    //a[0][1]={"0","2","4","6","8"};    jTable1 = new JTable(a,name);    //jPanel1.setLayout(borderLayout1);    border1 = BorderFactory.createEmptyBorder();    this.setLayout(borderLayout2);    jPanel1.setLayout(borderLayout3);    jScrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);    jScrollPane1.getViewport().setBackground(Color.white);    jScrollPane1.setBorder(border1);    jScrollPane1.setPreferredSize(new Dimension(450, 50));    jButton1.setText("begin");    jButton1.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton1_actionPerformed(e);      }    });    jLabel1.setBackground(Color.white);    jLabel1.setHorizontalAlignment(SwingConstants.CENTER);    jLabel1.setText("在输入或修改数据后单击该格或按回车使之生效。");    jPanel2.setLayout(gridBagLayout1);    jPanel2.setBackground(Color.white);    jLabel3.setHorizontalAlignment(SwingConstants.LEFT);    jLabel3.setHorizontalTextPosition(SwingConstants.CENTER);    jLabel3.setText("第1行:到达时间");    jLabel4.setText("请输入正整数,总服务时间不超过24:");    jLabel2.setText("第2行:服务时间");    this.add(jPanel1, BorderLayout.CENTER);    jPanel1.add(jScrollPane1, BorderLayout.CENTER);    jScrollPane1.getViewport().add(jTable1, null);    this.add(jPanel2, BorderLayout.NORTH);    jPanel2.add(jLabel3,       new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));    jPanel2.add(jLabel4,    new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));    jPanel2.add(jLabel2,     new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));    jPanel2.add(jButton1,         new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));    jPanel2.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0            ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 83, 11));  }  public void start() {  }  public void stop() {  }  public void destroy() {  }  void jButton1_actionPerformed(ActionEvent e) {    boolean isRight=true;    try{    for(int i=0;i<2;i++)      for(int j=0;j<5;j++){        n[i][j]=Integer.valueOf(a[i][j].toString()).intValue() ;        if(n[i][j]<0||n[i][j]>24){          isRight=false;        }      }    if(n[1][0]+n[1][1]+n[1][2]+n[1][3]+n[1][4]>24)      isRight=false;      if(isRight){        ShowFrame sf=new ShowFrame(this,n);        sf.show();      }    }catch (NumberFormatException ex){    JOptionPane.showMessageDialog(this,"输入不正确!请重新输入。","fail",JOptionPane.WARNING_MESSAGE);    }    if(!isRight)      JOptionPane.showMessageDialog(this,"输入不正确!请重新输入。","fail",JOptionPane.WARNING_MESSAGE);  }/*  public void paint(Graphics g){    g.drawLine(20,80,580,80);    for(int i=20;i<=580;i=i+20)      g.fillOval(i,75,2,6);  }*/}

⌨️ 快捷键说明

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