简化DFA-对于一确定型自动机M=(K,Σ,Δ,s, F)

源代码在线查看: windows.java

软件大小: 9 K
上传用户: dsdsads
关键词: DFA 自动机
下载地址: 免注册下载 普通下载 VIP

相关代码

				import java.awt.*;
				import java.awt.event.*;
				import javax.swing.*;
				public class windows extends JFrame {
					private int state,ch;
					private String data[][],finalstate;
					private JPanel panel1,panel2;
					private JTextField text[][];
					private JTextField text1,text2;
					private JButton button;
					private JButton buttons[][];
					public windows()
					{
						super("输入要简化的DFA");
						String State,C;
						State=JOptionPane.showInputDialog("输入状态数");
					    C=JOptionPane.showInputDialog("输入字符的个数");
					    state=Integer.parseInt(State);
					    ch=Integer.parseInt(C)+1;
					    text=new JTextField[state][ch];
					    Container container=getContentPane();
					    container.setLayout(new FlowLayout());
					    panel1=new JPanel();
					    GridLayout grid=new GridLayout(state,ch);
					    panel1.setLayout(grid);
					    for(int i=0;i					    	for(int j=0;j					    		{
					    		     text[i][j]=new JTextField("",10);
					    		     panel1.add(text[i][j]);
					    		}
					    container.add(panel1);
					    text1=new JTextField("输入终结状态所在的行数,以空格符间隔");
					    text1.setEditable(false);
					    container.add(text1);
					    text2=new JTextField("",10);
					    container.add(text2);
					    TextFieldHandler handler=new TextFieldHandler();
						button=new JButton("OK");
					    button.addActionListener(handler);
						container.add(button,BorderLayout.SOUTH);
						setSize(400,150);
						setVisible(true);
				  	}
					public windows(int St,int d,String da[])
					{
						super("转化后的DFA");
						int k=0;
						Container container=getContentPane();
						buttons=new JButton[St][d];
						container.setLayout(new GridLayout(St,d));
					    for(int i=0;i							for(int j=0;j								{
								    buttons[i][j]=new JButton(da[k++]);
								    container.add(buttons[i][j]);
								} 
						setSize(300,150);
						setVisible(true);
					}
					private class TextFieldHandler implements ActionListener{     
						public void actionPerformed(ActionEvent event) 
						{
							data=new String[state][ch];
							for(int i=0;i								for(int j=0;j									data[i][j]=text[i][j].getText();
							finalstate=text2.getText();
							method me=new method(state,ch,data,finalstate);
							windows application2=new windows(me.getcount(),ch,me.out);
						}
					}
					public static void main(String[] args) {
					    windows application1=new windows();
					    application1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
					}
				}			

相关资源