The Artima Developer Community
Sponsored Link

Java Answers Forum
To: Erikprice

1 reply on 1 page. Most recent reply: May 6, 2003 4:53 AM by Erik Price

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
brandon

Posts: 2
Nickname: cheezzer
Registered: May, 2003

To: Erikprice Posted: May 5, 2003 7:17 PM
Reply to this message Reply
Advertisement
This is Brandon again I figured out what I need to do so far. I do have a finished piece of code that won't compile, line 21 seems to be the problem ,but I can't figure it out. Could you give ago at this one. Thanks Eric.
Brandon
P.S. I was just checking for the caliber of who's out there when I asked such a simple question earlier, and your answer was more than sufficient. Thanks alot Eric
anyway here's the new code.

/*Name:Brandon Roy
Date:05-05-03
Assignment: Final Protect
File Name: Conversion Program
*/

import javax.swing.*;
public class Convert3

{
public static void main(String[] args) throws Exception
{
String inputString;
int intNumber;

do // This part of the program will continue to run as long as the
// number is greater than Zero.

{
String response = JOptionPane.showInputDialog (null,
" Please enter a distance in feet, or press 0/ZERO to quit",
JOptionPane.QUESTION_MESSAGE);
intNumber = Integer.parseInt(inputString);
if(intNumber > 0)
{
int mile = intNumber /1760/3;
int yard = (intNumber - (3*1760 * mile) ) /3;
int feet = intNumber - (mile *1760 * 3 + yard * 3);
JOptionPane.showMessageDialog(null, "MILES =" + mile + ",
YARDS = " + yard + ", FEET =" + feet);
}

else if (intNumber < 0) // This gives the program an alternate route.
{
JOptionPane.showMessgeDialog(null, "ERROR, Please enter another number.");
}
else
{
System.exit(0);
}
}
while (intNumber != 0) ;
}
}

//System.out.println("The is your conversion.");
//System.out.println( "Total Milege = " + mile);
//System.out.println( "Total Yards = " + yard);
//System.out.println( "Total Feet = " + feet);
//}

//}


Erik Price

Posts: 39
Nickname: erikprice
Registered: Mar, 2003

Re: To: Erikprice Posted: May 6, 2003 4:53 AM
Reply to this message Reply
Brandon you are really close.

Remember when you post some code if something doesn't work, that you should post the error message you get, since that can help identify the problem quickly. In this case, it's a "symbol not found" compiler error. This usually indicates that you've used a method, class, or other name that is unknown to the compiler. Often this is the result of not importing the right classes, but in this case, you've imported all the right classes.

The error messages are listed as this:

Convert3.java:18: cannot resolve symbol
symbol : method showInputDialog (<nulltype>,java.lang.String,int)
location: class javax.swing.JOptionPane
JOptionPane.showInputDialog (
^
Convert3.java:31: cannot resolve symbol
symbol : method showMessgeDialog (<nulltype>,java.lang.String)
location: class javax.swing.JOptionPane
JOptionPane.showMessgeDialog(null, "ERROR, Please enter another number.");
^

Those two error messages are both saying the same thing: the compiler has no idea where you're getting the method names from. In other words, the JOptionPane.showInputDialog(<nulltype>,java.lang.String,int) method is unknown to the compiler, and the JOptionPane.showMessgeDialog(<nulltype>,java.lang.String) method is unknown to the compiler.

If you check the JOptionPane Javadoc, you'll see that there's six methods named "showInputDialog":
showInputDialog(Component?parentComponent, Object?message)
showInputDialog(Component?parentComponent, Object?message, Object?initialSelectionValue)
showInputDialog(Component?parentComponent, Object?message, String?title, int?messageType)
showInputDialog(Component?parentComponent, Object?message, String?title, int?messageType,
    Icon?icon, Object[]?selectionValues, Object?initialSelectionValue)
showInputDialog(Object?message)
showInputDialog(Object?message,Object?initialSelectionValue)

Yet none of them conform to the signature that you've used. I think that the one you might have meant to use is the third one:
showInputDialog(Component?parentComponent, Object?message, String?title, int?messageType)

It uses the parentComponent (which in your code is going to be null since you're not using a parent component), the message itself, a title for the JOptionPane, and the message type. All you need to add is the title.

As for the second error message, if you look really closely at the error message I think you'll see what's wrong. Hint: there's no way that the showMessgeDialog method will be found by the compiler in any of the standard libraries. :)


Good luck.

Flat View: This topic has 1 reply on 1 page
Topic: Address Book Previous Topic   Next Topic Topic: JavaCertificate.com - Best of the Net

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use