Cannot resolve symbol

J

Jo

Does anyone know why I'm getting a "cannot resolve symbol method
showMessageDialog(java.lang.String)" error from this line here:

javax.swing.JOptionPane.showMessageDialog("Hello world.");

BTW It's just sitting in a normal class, not a frame.
 
C

Christophe Vanfleteren

Jo said:
Does anyone know why I'm getting a "cannot resolve symbol method
showMessageDialog(java.lang.String)" error from this line here:

javax.swing.JOptionPane.showMessageDialog("Hello world.");

BTW It's just sitting in a normal class, not a frame.

The compiler tells you this because there is no such method.

When you look at the API docs at
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JOptionPane.html,
you'll see the methods that do exist.
 
B

Babu Kalakrishnan

Jo said:
Does anyone know why I'm getting a "cannot resolve symbol method
showMessageDialog(java.lang.String)" error from this line here:

javax.swing.JOptionPane.showMessageDialog("Hello world.");

BTW It's just sitting in a normal class, not a frame.

Did you read the API documentation for the JOptionPane class ?

You're getting the error because the JOptionPane class does not have a
showMessageDialog method with a single String argument. All the variants
of the showMessageDialog take 2 or more arguments.

BK
 
R

Roedy Green

javax.swing.JOptionPane.showMessageDialog("Hello world.");

check the JavaDoc. There is no such method. I think you wanted this
one:

showMessageDialog(Component parentComponent, Object message, String
title, int messageType)


Brings up a dialog that displays a message using a default
icon determined by the messageType parameter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top