aspose file tools*
The moose likes Beginning Java and the fly likes Help with parameters for  JOptionPane.showMessageDialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with parameters for  JOptionPane.showMessageDialog" Watch "Help with parameters for  JOptionPane.showMessageDialog" New topic
Author

Help with parameters for JOptionPane.showMessageDialog

Jeff Ciaccio
Greenhorn

Joined: Nov 26, 2008
Posts: 25
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


Jeff Ciaccio, Java novice <br />Physics and AP Physics Teacher<br />Sprayberry High School <br />Marietta, GA
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2615
    
    9

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.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
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

Joined: Nov 26, 2008
Posts: 25
Thanks. It turned out to be a problem just before this line of code, but all is well now.
Travis Roberts
Greenhorn

Joined: Jul 13, 2009
Posts: 10

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
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
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

Joined: Nov 26, 2008
Posts: 25
I had a casting problem. I had a double but it was expecting an integer.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Thank you.
Jeff Ciaccio
Greenhorn

Joined: Nov 26, 2008
Posts: 25
Thank you - I apprecitate the help. Sorry I didn't post this earlier.

- Jeff
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with parameters for JOptionPane.showMessageDialog