小问题,你看看你的Dialog的构造方法的第一个参数,是Frame吧,这个就是Dialog显示定位的父窗口,如果你的button在Frame上,第一个参数就传this就可以了,至于JOptionPane的父窗口是Component,只要指定你的button所在的Component就行了,如this

解决方案 »

  1.   

    你打开的对话框的父窗口设置为null了
    而且model属性设置为true
    既是在关闭对话框前不能操作窗口这样的话对话框没有父窗口(null),
    再次激活此窗口,
    对话框会躲到后面去了解决办法:
    为对话框构造方法传递父窗口句柄
      

  2.   

    你打开的对话框的父窗口设置为null了
    而且model属性设置为true
    既是在关闭对话框前不能操作窗口这样的话对话框没有父窗口(null),
    再次激活此窗口,
    对话框会躲到后面去了解决办法:
    为对话框构造方法传递父窗口句柄
      

  3.   

    我的dialog就是这么写的
    给你个例子吧:
    import java.awt.*;
    import java.awt.event.*;
    import java.io.File;
    import javax.swing.*;
    import javax.swing.filechooser.*;
    import java.beans.*;public class Test extends JFrame {
    JFileChooser chooser = new JFileChooser();
    JButton button = new JButton("show file chooser ...");
    public Test() {
    super("Simple File Chooser Application");
    Container contentPane = getContentPane(); contentPane.setLayout(new FlowLayout());
    contentPane.add(button); button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    int state = chooser.showOpenDialog(null);
    File file = chooser.getSelectedFile(); if(file != null &&
       state == JFileChooser.APPROVE_OPTION) {
    JOptionPane.showMessageDialog(
    null, file.getPath());
    }
    else if(state == JFileChooser.CANCEL_OPTION) {
    JOptionPane.showMessageDialog(
    null, "Canceled");
    }
    else if(state == JFileChooser.ERROR_OPTION) {
    JOptionPane.showMessageDialog(
    null, "Error!");
    }
    }
    });
    }
    public static void main(String args[]) {
    JFrame f = new Test();
    f.setBounds(300,300,350,100);
    f.setVisible(true); f.setDefaultCloseOperation(
    WindowConstants.DISPOSE_ON_CLOSE);

    f.addWindowListener(new WindowAdapter() {
    public void windowClosed(WindowEvent e) {
    System.exit(0);
    }
    });
    }
    }
    我打开chooser后 没有进行任何操作(也没有关闭chooser),然后我去看浏览器,再返回我的界面后,chooser就不见了,只剩下frame,而且frame中的任何操作都不能进行了