?? ui.java.svn-base
字號:
/**
* UI.java
*
*
* @author 詹道楠
* @date 2008-5-14
*/
package execute;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.awt.Dimension;
public class UI extends JFrame implements Parameters {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JTextArea jtaConsole = null;
private JLabel jlConsole = null;
private JTextField jtfInput = null;
private JLabel jlInput = null;
private JButton jbOK_Button = null;
private JTextArea jtaPrinter = null;
private JLabel jlPrinter = null;
private JPanel jpProcessState = null;
private JPanel jpProcessID = null;
private JLabel jlProcessID = null;
private JTextField jtfProcessID = null;
private JPanel jpPC = null;
private JLabel jlPC = null;
private JTextField jtfPC = null;
private JPanel jpAC = null;
private JLabel jlAC = null;
private JTextField jtfAC = null;
private JPanel jpPSW = null;
private JLabel jlPSW = null;
private JPanel jpPrinter = null;
private JPanel jpConsole = null;
private JPanel jpInput = null;
private JPanel jpIR = null;
private JLabel jlIR = null;
private JTextField jtfIR = null;
private JPanel jpR0 = null;
private JLabel jlR0 = null;
private JTextField jtfR0 = null;
private JPanel jpR1 = null;
private JLabel jlR1 = null;
private JTextField jtfR1 = null;
private JPanel jpR2 = null;
private JLabel jlR2 = null;
private JTextField jtfR2 = null;
private JPanel jpR3 = null;
private JLabel jlR3 = null;
private JTextField jtfR3 = null;
private JPanel jpR4 = null;
private JLabel jlR4 = null;
private JTextField jtfR4 = null;
private JPanel jpR5 = null;
private JLabel jlR5 = null;
private JTextField jtfR5 = null;
private JPanel jpR6 = null;
private JLabel jlR6 = null;
private JTextField jtfR6 = null;
private JPanel jpR7 = null;
private JLabel jlR7 = null;
private JTextField jtfR7 = null;
private JScrollPane jspConsole = null;
private JScrollPane jspPrinter = null;
private JPanel jpProcessEditer = null;
private JLabel jlProcessEditer = null;
private JScrollPane jspProcessEditer = null;
private JTextArea jtaProcessEditer = null;
private JPanel jpReadyQueue = null;
private JLabel jlReadyQueue = null;
private JTextField jtfReadyQueue = null;
private JPanel jpInputQueue = null;
private JLabel jlInputQueue = null;
private JTextField jtfInputQueue = null;
private JPanel jpPrintQueue = null;
private JLabel jlPrintQueue = null;
private JTextField jtfPrintQueue = null;
private JPanel jpQueueMoniter = null;
private JPanel jpButtons = null;
private JButton jbExecute = null;
private JButton jbSave = null;
private JButton jbLoad = null;
private JButton jbClear = null;
private PCB pcb = null; // @jve:decl-index=0:
private SynchronizedQueue readyQueue = null; // @jve:decl-index=0:
private SynchronizedQueue inputQueue = null;
private SynchronizedQueue printQueue = null; // @jve:decl-index=0:
//private Keyboard keyboard = null; // @jve:decl-index=0:
private RunningMode mode = null;
private Memory mem;
private MemCell mc;
private JPanel jpPSWS = null;
private JLabel jlPSWs[] = new JLabel[8];
private JPanel jpControll = null;
private JLabel jlControllButton = null;
private JPanel jpControllButton = null;
private JPanel jpAutoMode = null;
private JRadioButton jrbAutoMode = null;
private JLabel jlAutoMode = null;
private JPanel jpManualMode = null;
private JRadioButton jrbManualMode = null;
private JButton jbNext = null;
private JTextField jtfAuto = null;
private JPanel jpMunal = null;
private JLabel jlManual = null;
private JPanel jpAuto = null;
private JLabel jlAuto = null;
private JLabel jlManualMode = null;
/**
* This is the default constructor
*/
public UI() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(844, 575);
this.setPreferredSize(new Dimension(500, 35));
this.setResizable(false);
this.setContentPane(getJContentPane());
this.setName("CPU");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("CPU Simulation");
this.setVisible(true);
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jlPrinter = new JLabel();
jlPrinter.setText("Printer");
jlPrinter.setPreferredSize(new Dimension(39, 20));
jlInput = new JLabel();
jlInput.setVerticalAlignment(SwingConstants.CENTER);
jlInput.setPreferredSize(new Dimension(34, 20));
jlInput.setText("Input");
jlConsole = new JLabel();
jlConsole.setText("Console");
jlConsole.setPreferredSize(new Dimension(46, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJpProcessState(), null);
jContentPane.add(getJpPrinter(), null);
jContentPane.add(getJpConsole(), null);
jContentPane.add(getJpInput(), null);
jContentPane.add(getJpProcessEditer(), null);
jContentPane.add(getJpQueueMoniter(), null);
jContentPane.add(getJpControll(), null);
}
return jContentPane;
}
/**
* This method initializes jtaConsole
*
* @return javax.swing.JTextArea
*/
private JTextArea getJtaConsole() {
if (jtaConsole == null) {
jtaConsole = new JTextArea();
jtaConsole.setEditable(false);
jtaConsole.setLineWrap(true);
jtaConsole.setWrapStyleWord(true);
jtaConsole.setText("");
}
return jtaConsole;
}
/**
* This method initializes jtfInput
*
* @return javax.swing.JTextField
*/
private JTextField getJtfInput() {
if (jtfInput == null) {
jtfInput = new JTextField();
jtfInput.setPreferredSize(new Dimension(4, 25));
}
return jtfInput;
}
/**
* This method initializes jbOK_Button
*
* @return javax.swing.JButton
*/
private JButton getJbOK_Button() {
if (jbOK_Button == null) {
jbOK_Button = new JButton();
jbOK_Button.setText("Input");
jbOK_Button.setMnemonic(KeyEvent.VK_UNDEFINED);
jbOK_Button.setPreferredSize(new Dimension(62, 25));
jbOK_Button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String s = jtfInput.getText();
if(s.length() >= 1) {
mc.setContent(s);
}
}
});
}
return jbOK_Button;
}
/**
* This method initializes jtaPrinter
*
* @return javax.swing.JTextArea
*/
private JTextArea getJtaPrinter() {
if (jtaPrinter == null) {
jtaPrinter = new JTextArea();
jtaPrinter.setEditable(false);
}
return jtaPrinter;
}
/**
* This method initializes jpProcessState
*
* @return javax.swing.JPanel
*/
private JPanel getJpProcessState() {
if (jpProcessState == null) {
jpProcessState = new JPanel();
jpProcessState.setLayout(null);
jpProcessState.setLocation(new Point(10, 260));
jpProcessState.setSize(new Dimension(250, 275));
jpProcessState.add(getJpProcessID(), null);
jpProcessState.add(getJpPC(), null);
jpProcessState.add(getJpAC(), null);
jpProcessState.add(getJpPSW(), null);
jpProcessState.add(getJpIR(), null);
jpProcessState.add(getJpR0(), null);
jpProcessState.add(getJpR1(), null);
jpProcessState.add(getJpR2(), null);
jpProcessState.add(getJpR3(), null);
jpProcessState.add(getJpR4(), null);
jpProcessState.add(getJpR5(), null);
jpProcessState.add(getJpR6(), null);
jpProcessState.add(getJpR7(), null);
}
return jpProcessState;
}
/**
* This method initializes jpProcessID
*
* @return javax.swing.JPanel
*/
private JPanel getJpProcessID() {
if (jpProcessID == null) {
jlProcessID = new JLabel();
jlProcessID.setText("Current Process ID");
jlProcessID.setPreferredSize(new Dimension(59, 25));
jlProcessID.setSize(new Dimension(120, 25));
jlProcessID.setLocation(new Point(0, 0));
jlProcessID.setHorizontalAlignment(SwingConstants.LEFT);
jpProcessID = new JPanel();
jpProcessID.setLayout(null);
jpProcessID.setLocation(new Point(35, 5));
jpProcessID.setSize(new Dimension(180, 25));
jpProcessID.add(jlProcessID, null);
jpProcessID.add(getJtfProcessID(), null);
}
return jpProcessID;
}
/**
* This method initializes jtfProcessID
*
* @return javax.swing.JTextField
*/
private JTextField getJtfProcessID() {
if (jtfProcessID == null) {
jtfProcessID = new JTextField();
jtfProcessID.setLocation(new Point(130, 0));
jtfProcessID.setEditable(false);
jtfProcessID.setHorizontalAlignment(JTextField.RIGHT);
jtfProcessID.setSize(new Dimension(50, 25));
}
return jtfProcessID;
}
/**
* This method initializes jpPC
*
* @return javax.swing.JPanel
*/
private JPanel getJpPC() {
if (jpPC == null) {
jlPC = new JLabel();
jlPC.setText(" PC");
jlPC.setHorizontalTextPosition(SwingConstants.LEFT);
jlPC.setSize(new Dimension(25, 25));
jlPC.setLocation(new Point(0, 0));
jlPC.setPreferredSize(new Dimension(16, 25));
jlPC.setHorizontalAlignment(SwingConstants.LEFT);
jpPC = new JPanel();
jpPC.setLayout(null);
jpPC.setLocation(new Point(0, 35));
jpPC.setSize(new Dimension(125, 25));
jpPC.add(jlPC, null);
jpPC.add(getJtfPC(), null);
}
return jpPC;
}
/**
* This method initializes jtfPC1
*
* @return javax.swing.JTextField
*/
private JTextField getJtfPC() {
if (jtfPC == null) {
jtfPC = new JTextField();
jtfPC.setLocation(new Point(40, 0));
jtfPC.setHorizontalAlignment(JTextField.RIGHT);
jtfPC.setEditable(false);
jtfPC.setSize(new Dimension(80, 25));
}
return jtfPC;
}
/**
* This method initializes jpAC
*
* @return javax.swing.JPanel
*/
private JPanel getJpAC() {
if (jpAC == null) {
jlAC = new JLabel();
jlAC.setLocation(new Point(0, 0));
jlAC.setPreferredSize(new Dimension(16, 25));
jlAC.setHorizontalAlignment(SwingConstants.LEFT);
jlAC.setHorizontalTextPosition(SwingConstants.LEFT);
jlAC.setText(" AC");
jlAC.setSize(new Dimension(25, 25));
jpAC = new JPanel();
jpAC.setLayout(null);
jpAC.setLocation(new Point(125, 35));
jpAC.setSize(new Dimension(125, 25));
jpAC.add(jlAC, null);
jpAC.add(getJtfAC(), null);
}
return jpAC;
}
/**
* This method initializes jtfAC
*
* @return javax.swing.JTextField
*/
private JTextField getJtfAC() {
if (jtfAC == null) {
jtfAC = new JTextField();
jtfAC.setLocation(new Point(40, 0));
jtfAC.setEditable(false);
jtfAC.setHorizontalAlignment(JTextField.RIGHT);
jtfAC.setSize(new Dimension(80, 25));
}
return jtfAC;
}
/**
* This method initializes jpPSW
*
* @return javax.swing.JPanel
*/
private JPanel getJpPSW() {
if (jpPSW == null) {
jlPSW = new JLabel();
jlPSW.setLocation(new Point(0, 0));
jlPSW.setPreferredSize(new Dimension(16, 25));
jlPSW.setHorizontalAlignment(SwingConstants.LEFT);
jlPSW.setHorizontalTextPosition(SwingConstants.LEFT);
jlPSW.setText("PSW");
jlPSW.setSize(new Dimension(33, 25));
jpPSW = new JPanel();
jpPSW.setLayout(null);
jpPSW.setLocation(new Point(0, 65));
jpPSW.setSize(new Dimension(250, 25));
jpPSW.add(jlPSW, null);
jpPSW.add(getJpPSWS(), null);
}
return jpPSW;
}
/**
* This method initializes jpPrinter
*
* @return javax.swing.JPanel
*/
private JPanel getJpPrinter() {
if (jpPrinter == null) {
BorderLayout borderLayout2 = new BorderLayout();
borderLayout2.setVgap(3);
jpPrinter = new JPanel();
jpPrinter.setLayout(borderLayout2);
jpPrinter.setLocation(new Point(10, 10));
jpPrinter.setSize(new Dimension(250, 240));
jpPrinter.add(jlPrinter, BorderLayout.NORTH);
jpPrinter.add(getJspPrinter(), BorderLayout.CENTER);
}
return jpPrinter;
}
/**
* This method initializes jpConsole
*
* @return javax.swing.JPanel
*/
private JPanel getJpConsole() {
if (jpConsole == null) {
BorderLayout borderLayout1 = new BorderLayout();
borderLayout1.setVgap(3);
jpConsole = new JPanel();
jpConsole.setLayout(borderLayout1);
jpConsole.setSize(new Dimension(300, 350));
jpConsole.setLocation(new Point(270, 10));
jpConsole.add(jlConsole, BorderLayout.NORTH);
jpConsole.add(getJspConsole(), BorderLayout.CENTER);
}
return jpConsole;
}
/**
* This method initializes jpInput
*
* @return javax.swing.JPanel
*/
private JPanel getJpInput() {
if (jpInput == null) {
jpInput = new JPanel();
jpInput.setLayout(new BorderLayout());
jpInput.setLocation(new Point(270, 490));
jpInput.setSize(new Dimension(300, 45));
jpInput.add(getJtfInput(), BorderLayout.CENTER);
jpInput.add(getJbOK_Button(), BorderLayout.EAST);
jpInput.add(jlInput, BorderLayout.NORTH);
}
return jpInput;
}
/**
* This method initializes jpIR
*
* @return javax.swing.JPanel
*/
private JPanel getJpIR() {
if (jpIR == null) {
jlIR = new JLabel();
jlIR.setLocation(new Point(0, 0));
jlIR.setPreferredSize(new Dimension(16, 25));
jlIR.setHorizontalAlignment(SwingConstants.LEFT);
jlIR.setHorizontalTextPosition(SwingConstants.LEFT);
jlIR.setText("IR");
jlIR.setSize(new Dimension(25, 25));
jpIR = new JPanel();
jpIR.setLayout(null);
jpIR.setLocation(new Point(0, 125));
jpIR.setSize(new Dimension(250, 25));
jpIR.add(jlIR, null);
jpIR.add(getJtfIR(), null);
}
return jpIR;
}
/**
* This method initializes jtfR
*
* @return javax.swing.JTextField
*/
private JTextField getJtfIR() {
if (jtfIR == null) {
jtfIR = new JTextField();
jtfIR.setLocation(new Point(40, 0));
jtfIR.setEditable(false);
jtfIR.setHorizontalAlignment(JTextField.RIGHT);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -