import ciku.*;//使用预定义类包
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class yh
{public static void main(String args[])
{	JFrame f=new JFrame();
	Container c=f.getContentPane();
	c.setLayout(new BorderLayout());
	JLabel lab=new JLabel("请输入");
	final JTextField txt=new JTextField(10);
	JPanel north=new JPanel();
	north.add(lab);
	north.add(txt);
	JButton btn1=new JButton("英译汉");
	JButton btn2=new JButton("汉译英");
	JPanel center=new JPanel();
	center.add(btn1);
	center.add(btn2);
	final JTextArea ta=new JTextArea(5,20);
	c.add(north,BorderLayout.NORTH);
	c.add(center,BorderLayout.CENTER);
	c.add(ta,BorderLayout.SOUTH);
	f.setSize(300,200);
	f.show();
	final yhciku yhck=new yhciku();
	btn1.addActionListener(new ActionListener()
	{	public void actionPerformed(ActionEvent e)
		{	String inputstr=txt.getText();
			boolean check=false;
			int i;
			for(i=0;i<yhck.english.length;i++)
			{	check=yhck.english[i].equalsIgnoreCase(inputstr);
				if(check)
				{	ta.setText(yhck.chinese[i]);
					break;
				}
			}
			if(i==yhck.english.length)
				ta.setText("无法翻译成中文！");
		}
	});
	btn2.addActionListener(new ActionListener()
	{	public void actionPerformed(ActionEvent e)
		{	String inputstr=txt.getText();
			boolean check=false;
			int i;
			for(i=0;i<yhck.chinese.length;i++)
			{	check=yhck.chinese[i].equalsIgnoreCase(inputstr);
				if(check)
				{	ta.setText(yhck.english[i]);
					break;
				}
			}
			if(i==yhck.chinese.length)
				ta.setText("无法翻译成英文！");
		}
	});
}
}
