?? makelistdlg.java
字號:
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 MakeListDLG extends JDialog { ProcessSchedule pSch; private JPanel panel1 = new JPanel(); private XYLayout xYLayout1 = new XYLayout(); private JScrollPane jScrollPane1 = new JScrollPane(); private JTextArea outTA = new JTextArea(); private JTextField arriveTime = new JTextField(); private JLabel jLabel1 = new JLabel(); private JLabel jLabel2 = new JLabel(); private JTextField serveTime = new JTextField(); private JButton add = new JButton(); private JButton finish = new JButton(); public MakeListDLG(Frame frame, String title, boolean modal) { super(frame, title, modal); try { jbInit(); pack(); } catch(Exception ex) { ex.printStackTrace(); } } public MakeListDLG(Frame frame, ProcessSchedule pSch) { this(frame, "添加進程/作業列表", false); this.pSch = pSch; } private void jbInit() throws Exception { panel1.setLayout(xYLayout1); jLabel1.setToolTipText(""); jLabel1.setText("進程/作業到達時間:"); jLabel2.setText("進程需要服務時間:"); add.setText("添加"); add.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { add_actionPerformed(e); } }); finish.setText("完成"); finish.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { finish_actionPerformed(e); } }); outTA.setEditable(false); getContentPane().add(panel1, BorderLayout.CENTER); panel1.add(jScrollPane1, new XYConstraints(182, 11, 207, 284)); jScrollPane1.getViewport().add(outTA, null); panel1.add(jLabel1, new XYConstraints(8, 27, -1, 22)); panel1.add(arriveTime, new XYConstraints(122, 29, 56, 17)); panel1.add(jLabel2, new XYConstraints(7, 54, 109, 17)); panel1.add(serveTime, new XYConstraints(122, 55, 56, 17)); panel1.add(add, new XYConstraints(20, 90, 131, 24)); panel1.add(finish, new XYConstraints(20, 132, 132, 27)); } void add_actionPerformed(ActionEvent e) { try { int at = Integer.parseInt(arriveTime.getText()); int st = Integer.parseInt(serveTime.getText()); if (at < 0 || st < 0) throw new Exception(); pSch.addProcess(new Process(st), at); outTA.append("到達時間:" + at + " 服務時間:" + st + "\n"); serveTime.setText(""); arriveTime.setText(""); } catch (Exception ex) { serveTime.setText(""); arriveTime.setText(""); JOptionPane.showMessageDialog(this, "兩個時間必須是大于0的整型數"); } } void finish_actionPerformed(ActionEvent e) { dispose(); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -