| | |
cannot resolve symbol symbol : variable JoptionPane
![]() |
•
•
Join Date: Sep 2006
Posts: 2
Reputation:
Solved Threads: 0
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
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
![]() |
Similar Threads
- Cannot Resolve Symbol (Java)
- BufferedReader error when try for integer (Java)
- Another "cannot find symbol" compiling error (Java)
- Need help debugging program (Java)
- Newbi can anyone help with methods and classes (Java)
- Code is written, but not working. (Java)
Other Threads in the IT Professionals' Lounge Forum
- Previous Thread: buying books
- Next Thread: design software
| Thread Tools | Search this Thread |
1gbit advertising advice amazon answers archive british broadband business businessprocesses career carrier censorship cern china cio collectiveintelligence connectivity consumer consumers corporateearnings datatransfer debtcollectors dictionary digg digital ebay ecommerce email employment environment facebook food government grid high-definition hottub infodelivery infotech intel internet interview ipod isp japan kindle lhc library malware marketing mit moonfruit news onlineshopping piracy piratebay pope porn program questions r&d religion remoteworking research retail security sex shopping simple skype smallbusiness smb sms socialmedia socialnetworking software softwareengineer spam speed spending startrek statistics stocks study stumbleupon survey tabletpc technology touch-screen touchscreen twitter uk videoinprint voips web webdeveloper windows words





