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
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.
精彩评论