• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

conversions

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have some code like this

int intTest;

intTest = JOptionPane.showInputDialog(this,"Add some text here", "test").length();

I will not compile I get this error:
Error(62,14): method showConfirmDialog(mypackage2.Frame1, int) not found in class javax.swing.JOptionPane

What does that mean. I suspect it is a conversion issue but can I convert test from a "TextBox" to a numeric value in one step??

Thanks
koda
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


intTest = JOptionPane.showInputDialog(this,"Add some text here", "test").length();




I will not compile I get this error:
Error(62,14): method showConfirmDialog(mypackage2.Frame1, int) not found in class javax.swing.JOptionPane



Your code and your problem are not related.
[ July 07, 2005: Message edited by: George Bolyuba ]
 
akoda Svenson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry when I posted I missed a line of code
code:
int intTest;
intTest = JOptionPane.showInputDialog(this,"Add some text here", "test").length();

JOptionPane.showConfirmDialog(this, intTest); //Line 62

koda
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your problem is that the signature for the method in line 62 is:

showInternalConfirmDialog(Component parentComponent, Object message)

but intTest is an int, which is a primitive and not an Object, so you must create an Object such as an Integer or a String from it.

So the second parameter passed to the method in line 62 should be something like either:

new Integer(intTest)
or
Integer.toString(intTest)

Hope that helps.

Struan
 
akoda Svenson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks that did it

Here is what I used

int intTest;

intTest = JOptionPane.showInputDialog(this,"Add some text here", "test").length();

JOptionPane.showConfirmDialog(this, Integer.toString(intTest));

It is strange to me that I have to use int for declaration but then Integer for toString???

koda
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's because an int is a primitive and thus does not support method calls. An Integer is an object that does support method calls.
 
akoda Svenson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Joel McNary:
That's because an int is a primitive and thus does not support method calls. An Integer is an object that does support method calls.



Thanks. I'll have to read on that.

koda
reply
    Bookmark Topic Watch Topic
  • New Topic