• Post Reply Bookmark Topic Watch Topic
  • New Topic

JOptionPane questions  RSS feed

 
Leslie Christ
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a guessing file for my final in Java Level 1.

I wrote:




but am getting an error message:
RandomGuess3.java:16: cannot find symbol
symbol : method showMessageDialog(java.lang.String)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog("The number I was thinking of: "+ranNu+"\nYour number was: "+answer);
^


Call me confused, but I don't know what this is saying.
 
Paddy Howard
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Leslie

I think the problem is a missing parameter in the call to JOptionPane.showMessageDialog(Component parentComponent, Object message). Try changing the last line to:

JOptionPane.showMessageDialog(null, "The number I was thinking of: "+ranNu+"\nYour number was: "+answer);

I think what the error message is saying is it cannot find an overload of showMessageDialog that only takes a single String parameter.
 
david jeche
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paddy Howard wrote:Hi Leslie

I think the problem is a missing parameter in the call to JOptionPane.showMessageDialog(Component parentComponent, Object message). Try changing the last line to:

JOptionPane.showMessageDialog(null, "The number I was thinking of: "+ranNu+"\nYour number was: "+answer);

I think what the error message is saying is it cannot find an overload of showMessageDialog that only takes a single String parameter.


yep his right i need to add null there before the string the programe should funaction fine afterwards
 
Campbell Ritchie
Marshal
Posts: 56521
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

You need to learn your way around the API documentation. If you look here, for example, you see the show... methods require a first argument which is a Component. [edit=add this next sentence in blue.] That means, you must provide it with that argument, otherwise no matching method can be found.[/edit] You can also see, if you scroll to the top of that page, that it tells you what happens if you pass null as an argument. There is a good explanation of what all the arguments do, and at the end of the first line/paragraph of ordinary text, a tutorials link which will give you even more useful information.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!