#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Posts
    14
    Rep Power
    0

    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.
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,996
    Rep Power
    9397
    The arguments you're giving don't quite match what's required by &raquo;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

    • Yawmark agrees
  4. #3
  5. Feelin' Groovy
    Devshed Supreme Being (6500+ posts)

    Join Date
    Aug 2001
    Location
    WDSMIA
    Posts
    10,135
    Rep Power
    5053
    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)));}}
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Posts
    14
    Rep Power
    0
    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.

IMN logo majestic logo threadwatch logo seochat tools logo