makepldlg.java~3~

来自「进程调度和存储管理模拟」· JAVA~3~ 代码 · 共 85 行

JAVA~3~
85
字号
package cn.edu.cauc.crab.ossimulate;import java.awt.*;import javax.swing.*;import com.borland.jbcl.layout.*;import java.awt.event.*;/** * <p>Title: OS simulate</p> * <p>Description: This is my home work.</p> * <p>Copyright: Copyleft (c) 2004</p> * <p>Company: CAUC</p> * @author Crab * @version 0.1 */public class makePLDLG extends JDialog {    PageReplacement pR;    private JPanel panel1 = new JPanel();    private XYLayout xYLayout1 = new XYLayout();    private JTextField pNumTA = new JTextField();    private JLabel jLabel1 = new JLabel();    private JButton addBT = new JButton();    private JButton finishBT = new JButton();    private JScrollPane jScrollPane1 = new JScrollPane();    private JTextArea outTA = new JTextArea();    public makePLDLG(Frame frame, String title, boolean modal) {        super(frame, title, modal);        try {            jbInit();            pack();        }        catch(Exception ex) {            ex.printStackTrace();        }    }    public makePLDLG(PageReplacement pR) {        this(null, "建立页面申请列表", false);        this.pR = pR;    }    private void jbInit() throws Exception {        panel1.setLayout(xYLayout1);        jLabel1.setText("页面号:");        addBT.setText("添加");        addBT.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(ActionEvent e) {                addBT_actionPerformed(e);            }        });        finishBT.setText("完成");        finishBT.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(ActionEvent e) {                finishBT_actionPerformed(e);            }        });        getContentPane().add(panel1);        panel1.add(pNumTA,   new XYConstraints(62, 48, 69, -1));        panel1.add(jLabel1,  new XYConstraints(10, 50, 48, 21));        panel1.add(addBT, new XYConstraints(35, 104, 68, 26));        panel1.add(finishBT,   new XYConstraints(34, 160, 68, 26));        panel1.add(jScrollPane1, new XYConstraints(175, 25, 195, 262));        jScrollPane1.getViewport().add(outTA, null);    }    void addBT_actionPerformed(ActionEvent e) {        try {            int pn = Integer.parseInt(pNumTA.getText());            if (pn < 0)                throw new Exception();            pR.addPage(pn);            outTA.append("页面号:" + pn +"\n");            pNumTA.setText("");        } catch (Exception ex) {            pNumTA.setText("");            JOptionPane.showMessageDialog(this, "页面号必须是大于0的整型数");        }    }    void finishBT_actionPerformed(ActionEvent e) {        dispose();    }}

⌨️ 快捷键说明

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