How do I get a MessageBox like information window to appear in Java?

Posted by John McClane on Stack Overflow See other posts from Stack Overflow or by John McClane
Published on 2010-01-16T04:48:32Z Indexed on 2010/05/08 12:28 UTC
Read the original article Hit count: 198

Filed under:
|
|
|

I'm learning Java and I have no idea how to do this.

I dragged a button on the form in Netbeans, double clicked it and it created this event:

@Action
public void HelloClickMethod() 
{
    JOptionPane.showMessageDialog(this, "The message!", "This is supposed to be the MessageBox title."); 
}

This is the exception the IDE brings up.

Cannot find symbol. Symbol: showMessageDialog()

Edit 1> Now I changed it to this:

@Action
public void HelloClickMethod()
{
    JOptionPane.showMessageDialog(this, "The message!", "This is supposed to be the MessageBox title.",JOptionPane.ERROR_MESSAGE);
}

However the IDE is saying I have an error in the word 'this'. "Cannot find symbol". I don't understand. Why is it so dificult and why are the errors so esoteric. :P

© Stack Overflow or respective owner

Related posts about java

Related posts about hello-world