?? window.java
字號:
package window;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import automation.Automation;
import automation.Input;
public class Window extends JFrame implements ActionListener
{
private static final long serialVersionUID = 1L;
/*
private Container container;
private JPanel top = new JPanel();
private JPanel top1 = new JPanel();
private JPanel top2 = new JPanel();
private JPanel top21 = new JPanel();
private JPanel top22 = new JPanel();
private JPanel media1 = new JPanel();
private JPanel media2 = new JPanel();
private JPanel media21 = new JPanel();
private JPanel media22 = new JPanel();
private JPanel media = new JPanel();
private JPanel buttom = new JPanel();
private JPanel buttom1 = new JPanel();
private JPanel buttom2 = new JPanel();
private JTextField address= new JTextField(40);
private JTextField inputstring= new JTextField(40);
private JLabel label = new JLabel("Please select the dat");
private JLabel label2 = new JLabel("Please input the String");
private JLabel label3 = new JLabel("The result:");
*/
private JTextArea dfa = new JTextArea("\n\n\n\n\n");
private JLabel fileLabel = new JLabel("Please Select DFA File: ");
private JTextField fileText = new JTextField(40);
private JButton fileButton = new JButton("From...");
private JLabel inputLabel = new JLabel("Please Type Read String: ");
private JTextField inputText = new JTextField(40);
private JButton inputButton = new JButton("Commit");
private JLabel result = new JLabel("Waiting for Initialized");
private Automation automation = new Automation();
private Input fileInput = new Input();
Window()
{
Container container = new Container();
container = getContentPane();
JPanel all = new JPanel();
JPanel fileChoosePanel = new JPanel(new FlowLayout());
JPanel dfaPanel = new JPanel();
JPanel stringInputPanel = new JPanel(new FlowLayout());
result.setHorizontalTextPosition(JTextField.CENTER);
fileText.setEditable(false);
dfa.setRows(5);
dfa.setEditable(false);
fileChoosePanel.add(fileLabel);
fileChoosePanel.add(fileText);
fileChoosePanel.add(fileButton);
dfaPanel.add(dfa);
stringInputPanel.add(inputLabel);
stringInputPanel.add(inputText);
stringInputPanel.add(inputButton);
all.add(fileChoosePanel, BorderLayout.NORTH);
all.add(dfaPanel);
all.add(stringInputPanel, BorderLayout.SOUTH);
container.add(all);
container.add(result, BorderLayout.SOUTH);
fileButton.addActionListener(this);
inputButton.addActionListener(this);
repaint();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == fileButton)
{
if(fileInput.execute() == -1)
{
String temp = "The File to Read is Illegal\n";
JOptionPane.showMessageDialog(null,temp, "DFA Reader", JOptionPane.WARNING_MESSAGE);
result.setText("Waiting for Initialized");
}
else
{
automation = fileInput.getAutomation();
if(automation.check())
{
result.setText("The DFA is Ready for Input");
String temp = "Automation Informations: \n";
temp += automation.getNumbers();
temp += "The Final States are " + automation.getFinalString();
temp += "The Figures are " + automation.getFigure();
dfa.setText(temp);
}
else
{
result.setText("The DFA is Illegal");
}
}
fileText.setText(fileInput.getReads());
repaint();
}
if(e.getSource() == inputButton)
{
boolean inputValid = true;
String text = inputText.getText();
String textA[] = new String[text.length()];
if(inputButton != null)
{
for(int i = 0; i < text.length(); i++)
{
String temp = String.valueOf(text.charAt(i));
if (automation.isFigure(temp))
{
textA[i] = String.valueOf(text.charAt(i));
}
else
{
inputValid = false;
break;
}
}
if (inputValid)
{
if(automation.accept(textA))
{
String temp = "The String You Type in is: \n" + text + "\n";
temp += "It is successfully accept by DFA Reader";
JOptionPane.showMessageDialog(null,temp, "DFA Reader", JOptionPane.INFORMATION_MESSAGE);
}
else
{
String temp = "The String You Type in is: \n" + text + "\n";
temp += "It is NOT accept by DFA Reader";
JOptionPane.showMessageDialog(null,temp, "DFA Reader", JOptionPane.WARNING_MESSAGE);
}
}
else
{
String temp = "The String You Type in is: \n" + text + "\n";
temp += "Please Type Only " + automation.getFigure();
JOptionPane.showMessageDialog(null,temp, "DFA Reader", JOptionPane.WARNING_MESSAGE);
}
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -