File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes JOptionPane problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JOptionPane problems" Watch "JOptionPane problems" New topic
Author

JOptionPane problems

James Brooks
Gunslinger
Ranch Hand

Joined: Aug 17, 2006
Posts: 165
Hi all,

If mySB is a stringbuffer, what is wrong with the following declaration? Error messages are:
C:\Documents and Settings\Owner.Mynotebook\Ch5ItIs\src\ch5itis\Chapter7Strings.java:29: <identifier> expected
JOptionPane.showMessageDialog(null, "The user ID is " + mySB);
C:\Documents and Settings\Owner.Mynotebook\Ch5ItIs\src\ch5itis\Chapter7Strings.java:29: illegal start of type
JOptionPane.showMessageDialog(null, "The user ID is " + mySB);
2 errors



Hello. My name is Inigo Montoya. You killed my father. Prepare to die.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Patrick Brooks:
...what is wrong with the following declaration? ...

It's not a declaration -- it's a method call. Nothing is wrong that that line of code, but it needs to be inside the body of a method.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
James Brooks
Gunslinger
Ranch Hand

Joined: Aug 17, 2006
Posts: 165
It was inside valid code, but when I closed NetBeans and reopened, it compiled and ran just fine. Strange.


-Patrick
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JOptionPane problems