文档库 最新最全的文档下载
当前位置:文档库 › 电子英汉词典源代码

电子英汉词典源代码



import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
public class Dictionary1 extends JFrame implements DocumentListener,ActionListener{
private static final long serialVersionUID = 1L;
JTextArea show;
JTextField input;
Dictionary1(){
input = new JTextField();
show = new JTextArea();
JPanel jp=new JPanel();
jp.setLayout(new GridLayout(1,2));
jp.add(input);
jp.add(show);
this.add(jp,BorderLayout.CENTER);
this.add(input,BorderLayout.NORTH);
this.validate();
input.getDocument().addDocumentListener(this);
this.setBounds(100,100,300,200);
this.setVisible(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void hangdle(){
String s=input.getText();
if(https://www.wendangku.net/doc/294692617.html,pareToIgnoreCase("我")==0){
show.setText("I");
}
else if(https://www.wendangku.net/doc/294692617.html,pareToIgnoreCase("你")==0){
show.setText("you");
}
else if(https://www.wendangku.net/doc/294692617.html,pareToIgnoreCase("他")==0){
show.setText("he");
}
else if(https://www.wendangku.net/doc/294692617.html,pareToIgnoreCase("you")==0){
show.setText("pron. 你;你们");
}
else if(https://www.wendangku.net/doc/294692617.html,pareToIgnoreCase("I")==0){
show.setText("pron. 我");
}
else if(https://www.wendangku.net/doc/294692617.html,pareToIgnoreCase("he")==0){
show.setText("pron. 他");
}
else show.setText("unfounded");
}

public void changedUpdate(DocumentEvent e) {
hangdle();
}

public void insertUpdate(DocumentEvent e) {
changedUpdate(e);
}
public void removeUpdate(DocumentEvent e) {
changedUpdate(e);
}
public void actionPerformed(ActionEvent e) {
hangdle();
}
}

public class MyWindow {
public static void main(String[] args) {
@SuppressWarnings("unused")
Dictionary1 dictionary= new Dictionary1();
}
}

相关文档