• Post Reply Bookmark Topic Watch Topic
  • New Topic

The public type AppletFrame must be defined in its own file?  RSS feed

 
sivasakam kumarsakam
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Error is

java.lang.Error: Unresolved compilation problem:
The public type AppletFrame must be defined in its own file

at Applets.AppletFrame.<init>(SampleFrame.java:33)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

i am execute this program in "eclipse".....
Thanks Sir In advance....
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can only have one public class in a source file, and the must should be named after the class; i.e., if the above is a complete source file, then the file must be named "AppletFrame.java".
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Public classes must be defined in a file with the same name. The cast must be the same as well.

If you want to know why, just search this board. That question has been asked before.


Not really Swing related; moving to a more appropriate forum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!