开发者

displaying message from console application

开发者 https://www.devze.com 2023-02-23 03:58 出处:网络
How do I pop up message in window from java console application?If I use JOptionPane, then I need to pass component which is visible.But if I want to show some warning or error from console applicatio

How do I pop up message in window from java console application?If I use JOptionPane, then I need to pass component which is visible.But if I want to show some warning or error from console application(which does not have an开发者_运维问答y window visible), Then I cant use JOptionPane. Also I want the displayed message to be shown on top of any other application(To get the attention of user ).

Thanks in advance.


You can use

JOptionPane.showMessageDialog(null, "Message goes here");

EDIT:

I tried

import javax.swing.JOptionPane;

public class Foo{
    public static void main(String a[])
    {
        JOptionPane.showMessageDialog(null, "Message goes here");
    }
}

and the output was

displaying message from console application

so your problem could be somewhere else?


If you really need a popup, make the component argument null and it will not have a parent.

0

精彩评论

暂无评论...
验证码 换一张
取 消