import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class wordsAnalysis extends JFrame implements ActionListener {
TextArea textResult, textSource; // 输入输出文本区
JButton buttonAnalysis;
String str; // 源程序字符串
char[] buf; // 源程序缓冲数组
// String strIden, strNum, strSym; //标识符
int offset = 0;
char ch;
int length;
// ArrayList identifier, symbol, number;
int idenOffset = 0;
int symOffset = 0;
int numOffset = 0;
public wordsAnalysis() {
JPanel panelSource = new JPanel();
JPanel panelResult = new JPanel();
JPanel panel = new JPanel();
panelSource.setLayout(new BorderLayout());
panelResult.setLayout(new BorderLayout());
panel.setLayout(new GridLayout(2, 1));
textSource = new TextArea();
textResult = new TextArea();
textResult.setEditable(false);
buttonAnalysis = new JButton("分析");
JLabel labelSource = new JLabel("请在下面文本区输入源码:", JLabel.LEFT);
JLabel labelResult = new JLabel("分析结果如下所示:", JLabel.LEFT);
panelSource.add(labelSource, "North");
panelSource.add(textSource, "Center");
panelResult.add(labelResult, "North");
panelResult.add(textResult, "Center");
panel.add(panelSource);
panel.add(panelResult);
Container c = this.getContentPane();
c.add(panel, "Center");
c.add(buttonAnalysis, "South");
buttonAnalysis.addActionListener(this);
setBounds(200, 100, 450, 450);
setVisible(true);
textResult.append("1->标识符,2->数字,3->界符" + '\n' + '\n');
}
public void analyse(String str) {