📄 dialogexample.java
字号:
import java.awt.*;
import java.awt.event.*;
public class DialogExample
extends WindowAdapter
implements ActionListener{
Frame f;
Button b;
Dialog d;
static public void main(String args[]) {
DialogExample de = new DialogExample();
de.go();
}
public void go() {
f = new Frame("Dialog Example");
b = new Button("Show Dialog");
b.addActionListener(this);
f.add("South",b);
d = new Dialog(f,"Dialog",true);
d.add("Center",new Label("Hello,I'm a Dialog"));
d.pack();
d.addWindowListener(this);
f.setSize(250,150);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
// 显示对话框
d.setVisible(true);
}
public void windowClosing(WindowEvent e) {
// 隐藏对话框
d.setVisible(false);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -