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. 😛
I can think of the following cause: you might not be “importing” the package containing JOptionPane. Try:
On top of your source file. Or, use
After questioner edit:
Other cause is the location of the method, if you are in an static context, you can’t use
this.