📄 ch9_43.java
字号:
import java.awt.*;
import java.awt.event.*;
public class ch9_43
{
TextField tf = new TextField(10);
Button b1=new Button("模态显示");
Button b2=new Button("非模态显示");
Frame f=new Frame("TestDialog");
Button b3=new Button("确定");
Dialog dlg = new Dialog(f, "Dialog Title", true);
FlowLayout fl=new FlowLayout();
ch9_43()
{
f.setLayout(fl);
f.add(tf);
f.add(b1);
f.add(b2);
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
dlg.setModal(true);
dlg.setVisible(true);
tf.setText("www.it315.org");
}
});
b2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
dlg.setModal(false);
dlg.setVisible(true);
tf.setText("www.it315.org");
}
});
f.setBounds(0,0,400,200);
f.setVisible(true);
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
dlg.setLayout(fl);
dlg.add(b3);
b3.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dlg.dispose();
}
});
dlg.setBounds(0,0,200,150);
}
public static void main(String[] args)
{
new ch9_43();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -