• 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

Help with parameters for JOptionPane.showMessageDialog

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried entering the following but I get an error:


The specific error is:
C:\Users\Dad\Documents\NetBeansProjects\CS8625\ParallelSpeedUpTutorial\src\com\yahoo\jeffciaParallelSpeedup\ParallelSpeedupGUI.java:631: cannot find symbol
symbol : variable frame
location: class com.yahoo.jeffciaParallelSpeedup.ParallelSpeedupGUI
JOptionPane.showMessageDialog(frame,"Eggs are not supposed to be green.","A plain message", JOptionPane.PLAIN_MESSAGE);
Note: C:\Users\Dad\Documents\NetBeansProjects\CS8625\ParallelSpeedUpTutorial\src\com\yahoo\jeffciaParallelSpeedup\ParallelSpeedupGUI.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
BUILD FAILED (total time: 0 seconds)

I think the problem is the first parameter. Can somebody please help me understand what the first parameter is?

Thanks
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Jeff, what is the first parm for the JOptionPane.showMessageDialog()? According to the API it's a "component". Now you put in "frame" and this variable not found. Then does your code have such variable? If no, you can put in null and it will compile.
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That first parameter is the Component over which the dialog window is to appear. If you write null the dialog window will appear in the centre of the screen. Beware: it may hide "behind" other windows.
 
Jeff Ciaccio
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. It turned out to be a problem just before this line of code, but all is well now.
 
Ranch Hand
Posts: 54
C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeff Ciaccio wrote:Thanks. It turned out to be a problem just before this line of code, but all is well now.




What is the fix?
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Travis Roberts wrote:What is the fix?

Quite right. It is always useful to know how somebody sorted out their problem; the solution is there in case anybody else has the same problem in future.

And welcome to JavaRanch
 
Jeff Ciaccio
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had a casting problem. I had a double but it was expecting an integer.
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.
 
Jeff Ciaccio
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you - I apprecitate the help. Sorry I didn't post this earlier.

- Jeff
 
I'm not sure if I approve of this interruption. But this tiny ad checks out:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic