对话框编程
import java.awt.event.*;import java.awt.*;
public class TestFileDialog
{
Frame myframe=new Frame();
Button btn1=new Button("打开模式对话框");
Button btn2=new Button("打开非模式对话框");
FileDialog dialog1=new FileDialog(myframe,"模式对话框",FileDialog.LOAD);
FileDialog dialog2=new FileDialog(myframe,"非模式对话框",FileDialog.SAVE);
public void init(){
//设置位置和大小
dialog1.setBounds(200,300,400,400);
dialog2.setBounds(200,300,400,400);
//设置监听事件
btn1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
dialog1.setVisible(true);
}
});
btn2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
dialog2.setVisible(true);
}
});
myframe.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
myframe.add(btn1);
myframe.add(btn2,BorderLayout.SOUTH);
myframe.pack();
myframe.setBounds(300,400,400,400);
myframe.setVisible(true);
}
public static void main(String[] args)
{
new TestFileDialog().init();
}
}
----------------解决方案--------------------------------------------------------
你这是要干嘛。。。
----------------解决方案--------------------------------------------------------