April 18th, 2007, 08:22 PM
-
Cannot Find Symbol Error using JOptionPane.showMessageDialog...
The past few times I got this error it was basically something I typed incorrectly that was causing the error. I have looked and looked at these two bits of code but I am unable to find what is wrong.
Error 1:
F:\ClassAverageAJP.java:19: cannot find symbol
symbol : method showMessageDialog(<nulltype>,java.lang.String,int)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null, "This program will ask the names and test scores"
Code:
JOptionPane.showMessageDialog(null, "This program will ask the names and test scores"
+ "of 5 students. \n It will then calculate the grade of each student. All of this"
+ "information \n will be placed in a file of your specification. Once all of the"
+ "grades have \n been entered, the program will calculate the class average and"
+ " place it in the file.", JOptionPane.INFORMATION_MESSAGE);
Error 2:
F:\ClassAverageAJP.java:50: cannot find symbol
symbol : method showMessageDialog(<nulltype>,java.lang.String,int)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null, "Each student's average score has been calculated "
Code:
JOptionPane.showMessageDialog(null, "Each student's average score has been calculated "
+ "\nalong with their appropriate grade. The class average has also been calculated."
+ "\nThe results can be found in this file: " + outputFileName + ".txt",
JOptionPane.INFORMATION_MESSAGE);
Any help is greatly appreciated.
Thanks.
April 18th, 2007, 08:45 PM
-
The arguments you're giving don't quite match what's required by »the method you're probably trying to use - you're missing the Title (java.lang.String) parameter.
Code:
public static void showMessageDialog(Component parentComponent,
Object message,
String title,
int messageType)
throws HeadlessException
("Cannot find symbol" doesn't just mean that you've typoed the name of something, but it could be that there's no method which takes the number/type of arguments you've given)
Comments on this post
April 18th, 2007, 08:47 PM
-
There is no showMessageDialog() method for JOptionPane that takes three arguments (i.e., null, String, and int).
~
Yawmark
class Sig{public static void main(String...args){\u0066or(int
\u0020$:"vÌÈÊ\"¤¾Àʲ¬Æ\"v¤Î¤\"²¤¨¸¬Æ".to\u0043h\u0061rArray()
)System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
+(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}
April 18th, 2007, 08:52 PM
-
Bah, I completely forgot the boxTitleString parameter. Thanks for pointing that out!(yet another easy fix
). Seems like there is always something I just can't find.
Thanks again.