cannot resolve symbol symbol : variable JoptionPane

Reply

Join Date: Sep 2006
Posts: 2
Reputation: ghackprime is an unknown quantity at this point 
Solved Threads: 0
ghackprime ghackprime is offline Offline
Newbie Poster

cannot resolve symbol symbol : variable JoptionPane

 
0
  #1
Sep 12th, 2006
I no the problem is not with the program its with my pc. I am able to compile this program fine on my school's pc but i can't on my laptop.

The program is
public class SwingIO
{
public static void main(String[] args)
{
/*
(To contrast this sample with the ConsoleIO program, note
that no "throws IOException" clause is required above in
the declaration of the method: main. Note also that the
swing input routines do not require declarations analagous
to those of InputStreamReader and BufferedReader objects
of the ConsoleIO program.)
*/

/*
Following are the input variables of this sample program.
Note that numbers must be read in as Strings and then
converted.
*/
String name;
String numberString; // Each number will be read here in turn

/*
Numeric inputs will be converted to ints and placed in
these two variables.
*/
int number1, number2;

/*
Following produces an input window to pop us with the prompt
message shown in the parameter. Whatever the user enters is
stored in the name variable.
*/
name = JOptionPane.showInputDialog("What is your first name?");

/*
Read and convert the first integer. Note: the program will
crash in the conversion process if a value entered for either
the first or second integer are not valid integer numbers.
*/
numberString = JOptionPane.showInputDialog(
"Enter first integer value:");
number1 = Integer.parseInt(numberString);

/*
Read and convert the second integer (see note just above).
*/
numberString = JOptionPane.showInputDialog(
"Enter second integer value:");
number2 = Integer.parseInt(numberString);

// Calculates and displays the answer
JOptionPane.showMessageDialog(null, "Hello, " + name + "!" + "\n" +
"The sum of " + number1 + " and " + number2 +
" is " + (number1 + number2) + ".");
}
}

And the error message is

C:\Documents and Settings\Admin\My Documents\Java Programs\SwingIO.java:34: cannot resolve symbol
symbol : variable JOptionPane
location: class SwingIO
name = JOptionPane.showInputDialog("What is your first name?");
^
C:\Documents and Settings\Admin\My Documents\Java Programs\SwingIO.java:41: cannot resolve symbol
symbol : variable JOptionPane
location: class SwingIO
numberString = JOptionPane.showInputDialog(
^
C:\Documents and Settings\Admin\My Documents\Java Programs\SwingIO.java:48: cannot resolve symbol
symbol : variable JOptionPane
location: class SwingIO
numberString = JOptionPane.showInputDialog(
^
C:\Documents and Settings\Admin\My Documents\Java Programs\SwingIO.java:53: cannot resolve symbol
symbol : variable JOptionPane
location: class SwingIO
JOptionPane.showMessageDialog(null, "Hello, " + name + "!" + "\n" +
^
4 errors

Tool completed with exit code 1
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 2
Reputation: ghackprime is an unknown quantity at this point 
Solved Threads: 0
ghackprime ghackprime is offline Offline
Newbie Poster

Re: cannot resolve symbol symbol : variable JoptionPane

 
0
  #2
Sep 12th, 2006
Also i should have mentioned that i am useing the same compiler on my laptop that i us at school "Textpad". My school has Java 2 SDK ,SE v1.4.2_12 installed. I have that and J2SE Runtime Enviroment 5.0 update 6.

Any advise?
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 84
Reputation: rinoa04 is on a distinguished road 
Solved Threads: 4
rinoa04's Avatar
rinoa04 rinoa04 is offline Offline
Junior Poster in Training

Re: cannot resolve symbol symbol : variable JoptionPane

 
0
  #3
Sep 16th, 2006
There is nothing wrong with your program nor your compiler. It is only that you forgot to include this statement:

import javax.swing.JOptionPane;

That is why the compiler doesn't recognise JOptionPane function.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC