On p. 371, there is code for a SimpleGui3C class. The first bug I encountered is that the code for the paintComponent method of MyDrawPanel is supposed to be on p. 347, and it's not. (I think the right code is on page 367).
But that's not my real problem, which is that I'm using Eclipse and it is giving an error. It says: "The serializable class MyDrawPanel does not declare a static final serialVersionUID field of type long."
HFJ doesn't say anything about this. So, I used the "QuickFix" option in Eclipse to fix it, choosing "Add default serial version ID."
However, there is still a problem. When I try to run this project as an application, I get a dialog box which says "Searching for main types...", and some scary-looking dialog box which says to choose a run type, but doesn't include "Application." So now my project won't build. :-(. Please help. Thank you in advance for any help.
If you are using Eclipse, you should have a tree on the left with all the classes in your project in.
Navigate to the left window with the list of classes in.
Right-click the name of the class which has the main method in
From the drop-down list choose Run as.
From the second drop-down list choose Run as: Java Application, and click that.
That should get rid of the "scary box." Next time you run your app, use the green circle icon near the top left of the Eclipse window, which has a balloon help "run previously run application" or something similar.
BTW: When you get your error "The serializable class MyDrawPanel does not declare a static final serialVersionUID field of type long," what colour does it come up in? I get that all the time. I get a yellow triangle next to the warning: this is Eclipse's shorthand for a "warning," which will still allow the app to run, as opposed to an "error," which is red with a cross on. You can't get your app to run if it has an "error" in. So you only need to correct "errors" (red).
There is discusssion on part of this thread about what an SUID means, but it is not beginner's stuff. There is also discussion of serialization in Horstmann C, Cornell G, Core Java 2: vol I: Fundamentals, Upper Saddle River:Sun Microsystems Press/Prentice Hall 2004, page 667ff particularly page 680. But again, it is complicated stuff. You don't have to read it if you don't want to.
Error: I said "run" when it should have been "run as." [ June 15, 2006: Message edited by: Campbell Ritchie ]
posted 14 years ago
oh, thanks so much! I was trying to run the application from the project level instead of the file level, so I was getting that "scary looking dialog." Because you told me exactly where to click, everything is working fine now. Thanks.
posted 14 years ago
Glad to be able to help. It is nice when people get their applications to work.