⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testdialog.java

📁 这是一个java程序
💻 JAVA
字号:
//演示对话框Dialog的使用
import java.awt.*; 
import java.awt.event.*;
public class TestDialog{
	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();
	TestDialog(){
		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 TestDialog();		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -