📄 10.20dialogtest.java
字号:
import java.awt.*;
import java.awt.event.*;
public class DialogTest extends Frame implements ActionListener{
Frame f;
Dialog d;
Button b;
Label l;
public void go(){
f = new Frame ("对话框");
d = new Dialog (f, "ok", false); //创建一个对话框
b = new Button ("ok");
l = new Label ("Welcome to come!");
f.setBounds(200,200,200,200); //设置版面显示区域
f.add ("Center",b);
d.add ("Center",l);
d.setBounds(300,300,150,100); //设置对话框显示区域
b.addActionListener (this); //设置事件监听
f.setVisible (true); //设置面板可见
}
public void actionPerformed (ActionEvent e){ //事件处理函数
//按下f上的按钮时
d. setVisible (true); //设置对话框可见
}
public static void main (String args[]){
DialogTest e=new DialogTest();
e.go();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -