• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot find symbol for JOptionpane?  RSS feed

 
John Sing
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • 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?
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • 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.
 
Pedro Pelizzaro
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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
  • 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: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a very close look at the Integer class. Look particularly at the letter I.
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • 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
  • 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: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mustn't let it worry you. Everybody else makes that sort of mistake, too.
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Mark post as helpful
  • send pies
  • 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.
 
Charles D. Ward
Ranch Hand
Posts: 99
1
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!