• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Cannot find symbol for JOptionpane?

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I am having a problem in my program and I have no idea how to fix it. It says it cannot find the symbol when I try to use a input box. I already imported JOptionpane so I am not sure what I should do to fix this. Here is my code




and here are the errors I am currently getting

"[line: 21]
Error: cannot find symbol
symbol: method showInputBox(java.lang.String)
location: class javax.swing.JOptionPane

[line: 22]
Error: cannot find symbol
symbol: method showInputBox(java.lang.String)
location: class javax.swing.JOptionPane

[line: 23]
Error: cannot find symbol
symbol: method showInputBox(java.lang.String)
location: class javax.swing.JOptionPane

[line: 24]
Error: cannot find symbol
symbol: method showInputBox(java.lang.String)
location: class javax.swing.JOptionPane

[line: 26]
Error: cannot find symbol
symbol: method showInputBox(java.lang.String)
location: class javax.swing.JOptionPane

[line: 28]
Error: cannot find symbol
symbol: method showInputBox(java.lang.String)
location: class javax.swing.JOptionPane

[line: 30]
Error: cannot find symbol
symbol: method showInputBox(java.lang.String)
location: class javax.swing.JOptionPane

[line: 32]
Error: cannot find symbol
symbol: method showInputBox(java.lang.String)
location: class javax.swing.JOptionPane"

What should I do to fix this?
 
Marshal
Posts: 76856
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I never thought JOptionPane had any showXXXBox methods. I have only seen showXXXDialog. You can find out all about it in the Jave™ Tutorials.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think showInputBox is a thing. Try replacing "Box" for "Dialog". By the way, your average method doesn't need a parameter(the (int av) thing) . In fact it never gets used at all.

I've tested with these changes and it works perfectly.

Hope it helps.
 
John Sing
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:I never thought JOptionPane had any showXXXBox methods. I have only seen showXXXDialog. You can find out all about it in the Jave™ Tutorials.



Well I feel stupid... But I am still getting an error on this line of my code



the error I get is
" [line: 37]
Error: cannot find symbol
symbol: method parseint(java.lang.String)
location: class java.lang.Integer"

As far as I can tell I have done nothing wrong. How do I fix this?

Also classPrep is a string and classPrepUse is a int. I use the same exact way of coding earlier in the code and it works fine.
 
Campbell Ritchie
Marshal
Posts: 76856
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a very close look at the Integer class. Look particularly at the letter I.
 
Campbell Ritchie
Marshal
Posts: 76856
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Sing wrote:. . . Also classPrep is a string and classPrepUse is a int. . . .

What dreadful variable names. You should be able to tell what a variable means by reading its name; you cannot do that for those variables.
 
John Sing
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Have a very close look at the Integer class. Look particularly at the letter I.



Thanks again for pointing out another stupid mistake. I normally don't make stupid mistakes like this but I am very tired and I have a lot of work to do so yeah thanks again your a life saver.
 
Campbell Ritchie
Marshal
Posts: 76856
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mustn't let it worry you. Everybody else makes that sort of mistake, too.
 
Sheriff
Posts: 8521
615
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A bit on code style part.

1. You got about 80% variables which starts with an upper case. These should be starting with lower case. You got some of them correct as finalGrade - follow that convention.
1.1. Also quite difficult to distinct logically Grade1 and Grade1use. First one I could guess, about the second have no idea unless I read all class. I'd say get rid of Grade1,2,3... and keep them within local scope of constructor and only have Grade1use as instance. Of course with different name.
2. There is no strong reason to shorten the class name StudInfo too. Why not to keep it clear StudentInfo or StudentInformation?
3. average method. It is not clear too, what it suppose to do? Average of what? Just print it? Return something?

The code style part in assignments are important, you could easily loose 20% of your mark only because of poor and misleading variables, methods names. On the more important side, you can confuse yourself, and get incorrect functionality, which could help you loose the way more points.
 
Ranch Hand
Posts: 99
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Liutauras Vilda wrote:A bit on code style part.

1. You got about 80% variables which starts with an upper case. These should be starting with lower case. You got some of them correct as finalGrade - follow that convention.
1.1. Also quite difficult to distinct logically Grade1 and Grade1use. First one I could guess, about the second have no idea unless I read all class. I'd say get rid of Grade1,2,3... and keep them within local scope of constructor and only have Grade1use as instance. Of course with different name.
2. There is no strong reason to shorten the class name StudInfo too. Why not to keep it clear StudentInfo or StudentInformation?
3. average method. It is not clear too, what it suppose to do? Average of what? Just print it? Return something?

The code style part in assignments are important, you could easily loose 20% of your mark only because of poor and misleading variables, methods names. On the more important side, you can confuse yourself, and get incorrect functionality, which could help you loose the way more points.



There's also the terrible, inconsistent indentation.
 
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic