import java.awt.*;
import java.awt.event.*;
public class Myproject extends Frame implements ActionListener {
public static void main(String args[]) {
TextArea ta;
Button button;
Frame fr = new Frame("KOF");
ta = new TextArea();
fr.add(ta,BorderLayout.CENTER);
button = new Button("读取");
fr.add(button,BorderLayout.SOUTH);
//button.addActionListene(this);
fr.setSize(200,100);
fr.setVisible(true);
FileDialog dialog = new FileDialog(fr,"My FileDialog");
dialog.setVisible(true);
String fname = dialog.getDirectory() + dialog.getFile();
fr.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent event) {
Object dialog = null;
if(dialog == null) {
dialog = new FileDialog(this,"My FileDialog");
}
((Component) dialog).setVisible(true);
}
public Myproject(String str) {
super(str);
}
}
请问要怎么改才能当自己点按钮的时候才会弹出对话框 ,修改以后请给我全部代码.多谢!!