java对话框的关闭问题
importjava.awt.*;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener...
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class Test_Dialog extends WindowAdapter implements ActionListener {
public void creat(){
fra=new Frame("OK");
bu1=new Button("'sda");
fra.setSize(300, 300);
fra.setVisible(true);
fra.addWindowListener(this);
fra.add(bu1);
bu1.addActionListener(this);
}
public static void main(String[] args) {
Test_Dialog obj=new Test_Dialog();
obj.creat();
}
private Frame fra;
private Button bu1;
@Override
public void actionPerformed(ActionEvent e) {
final Dialog dia=new Dialog(fra,"源于",true);
dia.setSize(100, 100);
dia.setVisible(true);
dia.addWindowListener(new WindowAdapter(){
public void windowCloing(WindowEvent e){
dia.dispose();
}
});
}
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
只是创建一个窗口+按钮,通过按钮去连接对话框
但为什么对话框关闭不了? 展开
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class Test_Dialog extends WindowAdapter implements ActionListener {
public void creat(){
fra=new Frame("OK");
bu1=new Button("'sda");
fra.setSize(300, 300);
fra.setVisible(true);
fra.addWindowListener(this);
fra.add(bu1);
bu1.addActionListener(this);
}
public static void main(String[] args) {
Test_Dialog obj=new Test_Dialog();
obj.creat();
}
private Frame fra;
private Button bu1;
@Override
public void actionPerformed(ActionEvent e) {
final Dialog dia=new Dialog(fra,"源于",true);
dia.setSize(100, 100);
dia.setVisible(true);
dia.addWindowListener(new WindowAdapter(){
public void windowCloing(WindowEvent e){
dia.dispose();
}
});
}
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
只是创建一个窗口+按钮,通过按钮去连接对话框
但为什么对话框关闭不了? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询