Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/347.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模式对话框_Java_Swing_Jdialog - Fatal编程技术网

主命令行中的Java模式对话框

主命令行中的Java模式对话框,java,swing,jdialog,Java,Swing,Jdialog,我可以从java命令行程序创建一个Jframe对话框,并在继续执行主程序之前等待返回吗 下面的代码不起作用,但这是我的想法 public static void main(String args[]){ Dialog dl = new DialogGui(); dl.setVisable(true); while(dl.isVisiabl(){ //wait.... } } 如果它能够从Jframe返回数据,那么它将是一个加号。不要使

我可以从java命令行程序创建一个Jframe对话框,并在继续执行主程序之前等待返回吗

下面的代码不起作用,但这是我的想法

public static void main(String args[]){
     Dialog dl = new DialogGui();
     dl.setVisable(true);
     while(dl.isVisiabl(){
         //wait....
     }
 }

如果它能够从Jframe返回数据,那么它将是一个加号。

不要使用
Jframe
,使用
JDialog

您正在查找一个预打包的对话框工厂:。在方法返回之前,它的对话框都是模态和块。例如,确认对话框:

if ( JOptionPane.showConfirmDialog( null, "this is a message",
                    "this is a title", JOptionPane.YES_NO_OPTION, 
                        JOptionPane.WARNING_MESSAGE ) == JOptionPane.YES_OPTION )
{
    // do something since the user selected yes
}

对话框可合理定制,请参阅文档。

不要使用
JFrame
,使用
JDialog

您正在查找一个预打包的对话框工厂:。在方法返回之前,它的对话框都是模态和块。例如,确认对话框:

if ( JOptionPane.showConfirmDialog( null, "this is a message",
                    "this is a title", JOptionPane.YES_NO_OPTION, 
                        JOptionPane.WARNING_MESSAGE ) == JOptionPane.YES_OPTION )
{
    // do something since the user selected yes
}
对话框可合理定制,请参见文档