Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Swing在JDialog之后不呈现_Java_Swing_Jdialog - Fatal编程技术网

Java Swing在JDialog之后不呈现

Java Swing在JDialog之后不呈现,java,swing,jdialog,Java,Swing,Jdialog,我创建了一个自定义JDialog,其构造函数如下: public class SampleMain extends JDialog public SampleMain (MainFrame mf, String [] args){ super (mf, "Choose a Folder" ,true ); /*Here I Create the View*/ } JDialog有一个带有操作侦听器的按钮: class EnterListener implements A

我创建了一个自定义JDialog,其构造函数如下:

public class SampleMain  extends JDialog

public  SampleMain (MainFrame mf, String [] args){

    super (mf, "Choose a Folder" ,true );
    /*Here I Create the View*/
}
JDialog有一个带有操作侦听器的按钮:

class EnterListener implements ActionListener  {
    public void actionPerformed(ActionEvent e) {

        /*Some Logic Here*/

        setVisible(false);
        dispose();


    }
}
我从另一个JFrame调用此对话框:

public class MainFrame extends JFrame
调用扩展JDialog的JButton侦听器:

class TreePathListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {

        String [] list = {tfUsr.getText() ,tfPas.getText() ,tfRepo.getText()};

        SampleMain sm = new SampleMain (MainFrame.this ,list );

        txtPath.setText(sm.getSelectedPath());

    }
}
现在来看问题: 在单击视图之前,扩展JDialog JFrame如下所示:

public class SampleMain  extends JDialog

public  SampleMain (MainFrame mf, String [] args){

    super (mf, "Choose a Folder" ,true );
    /*Here I Create the View*/
}

之后:

你知道我该怎么解决吗

谢谢

下面是一个示例项目:任何人都可以使用它作为miglyout的自定义JDialog示例

编辑:

我在最初的项目中发现了这个问题,我在扩展的dialog类中有这段代码

static {
    try {
        String className = UIManager.getSystemLookAndFeelClassName();
        UIManager.setLookAndFeel(className);
    } catch (Exception ignore) {
    }
}

删除该选项修复了问题。

发布您的演示问题的帖子。这是SSCCE,一切都相关。如果我要删除问题的任何部分,它将必须理解问题是什么以及可能导致问题的原因。这不是SSCCE。我无法编译和执行代码来查看所描述的行为。我将在明天创建一个可执行版本,并将其发布在这里。谢谢你愿意帮忙!我上传了示例项目,多亏了你,我发现了问题。我得到了一个带有问题静态部分的自定义代码。移除那个静态块解决了这个问题。