本域(用于现实程序每一步的操作和影响,不可编辑)
private JTextArea CPUTextArea, statuesTextArea; //后备队列PCB数组,就绪、挂起,——内存(可分分区表) PCBRecords backupPCB, readyPCB, suspendedPCB; private MemoryRecords memoryItems; private boolean flag = false; /** * 主函数 * @param args
* @throws IOException */
public static void main(String[] args) throws IOException {
new CPUScheduling().initFrame(); }
//初始化Frame
public void initFrame() {
backupList = new JList();
backupList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
backupList.setVisibleRowCount(BackupBAK_LIST_ROWS);
backupList.setFixedCellWidth(BackupBAK_CELL_SIZE);
suspendList = new JList();
suspendList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
suspendList.setVisibleRowCount(Suspend_LIST_ROWS);
suspendList.setFixedCellWidth(Suspend_CELL_SIZE);
readyList = new JList();
readyList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
readyList.setVisibleRowCount(Ready_LIST_ROWS);
readyList.setFixedCellWidth(Ready_CELL_SIZE);
memoryList = new JList();
memoryList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
memoryList.setVisibleRowCount(Memory_LIST_ROWS);
memoryList.setFixedCellWidth(Memory_CELL_SIZE);
suspendButton = new JButton(\挂起(3)\ addToBAKButton = new JButton(\加入后备(1)\ addToReadyButton = new JButton(\加入就绪(2)\ resetButton = new JButton(\重置(0)\ umountButton = new JButton(\解挂(4)\ removeButton = new JButton(\移除(5)\ startButton = new JButton(\调度开始(Enter)\ pauseButton = new JButton(\暂停(Pause)\ resetSyatemButton = new JButton(\重置系统
(Backspace)\
helpButton = new JButton(\帮助(H)\
priorityJRB = new JRadioButton(\优先级(Page Up)\
timesliceJRB = new JRadioButton(\时间片(Page Down)\
suspendButton.setToolTipText(\双击进程可以直接挂起!\
umountButton.setToolTipText(\双击解挂按钮的正上方的进程,可以直接解挂!\
removeButton.setToolTipText(\双击移除按钮的正上方的进程,可以直接移除!\
startButton.setBackground(Color.GREEN); pauseButton.setBackground(new Color(0,150,255));
resetSyatemButton.setBackground(Color.RED); backupTotalLabel = new JLabel(\总计:\ backupTotalTextField = new JTextField(\TOTAL__TEXTFIELD_SIZE);
backupTotalTextField.setEditable(false);
suspendTotalLabel = new JLabel(\总计:\ suspendTotalTextField = new JTextField(\TOTAL__TEXTFIELD_SIZE);
suspendTotalTextField.setEditable(false); timesliceSizeLabel = new JLabel(\时间片:\ timesliceJtf = new JTextField(\ timesliceJtf.setEditable(true);
CPUTextArea CPU_COLS);
CPUTextArea.setEditable(false);
statuesTextArea = new JTextArea(STATUS_ROWS, STATUS_COLS);
statuesTextArea.setEditable(false);
/* north panel*/
JPanel northPanel = new JPanel(new GridLayout(1, 3));
PCBItemPanel = new JPanel(new FlowLayout()); PCBItemPanel.setBorder(
BorderFactory.createTitledBorder(\项目信息\
= new JTextArea(CPU_ROWS,