📄 dialogtest.java
字号:
package ptu;
import java.awt.*;
import java.awt.event.*;
public class DialogTest extends Frame{
Dialog dialog1;
Button b1,db1,db2;
public DialogTest()
{
this.setTitle("半闭测试");
this.setSize(200, 200);
this.setLayout(new FlowLayout());
dialog1=new Dialog(this,"关闭确认");
dialog1.setModal(true);
dialog1.setLayout(new FlowLayout());
dialog1.setSize(100, 100);
b1=new Button("退出");
db1=new Button("确定");
db2=new Button("取消");
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
// TODO 自动生成方法存根
dialog1.show();
}
});
db1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO 自动生成方法存根
System.exit(0);
}
});
db2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO 自动生成方法存根
dialog1.dispose();
}
});
this.add(b1);
dialog1.add(db1);
dialog1.add(db2);
}
public static void main(String[] args)
{
DialogTest test1=new DialogTest();
test1.show();
test1.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent arg0) {
// TODO 自动生成方法存根
System.exit(0);
}
});
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -