aspose file tools*
The moose likes Applets and the fly likes help me,i can't fix this code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "help me,i can Watch "help me,i can New topic
Author

help me,i can't fix this code

dhuha al khoiri
Greenhorn

Joined: Apr 17, 2012
Posts: 24


i found error in this code,and i try to fix it with eclipse,but i can't,i didnt know why,can all of you help me fix this code?

and the error in public class SwingApplet,i try to fix it,but i am still can't fix it,altough i always try,help me please


Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Are you going to tell us what the problem with this code is, or are we supposed to guess?
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232

without knowing how we will give you answers?


SCJP 6- 91%, IBM DB2, IBM RAD Certified
dhuha al khoiri
Greenhorn

Joined: Apr 17, 2012
Posts: 24

the error is in:

public class SwingApplet extends JApplet {

the error said: the public type SwingApplet must be defined in its own file

why this can be happen??

and i try to fix it with eclipse,but the code still error,altough i was try so many times,i still can't recognize where is the error from this code

please help me,thanks...
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4658
    
    5

dhuha, you've been told about using code tags when you posted in this thread. I've added them for you, but you have to form a habit of reading responses to your posts and learning from them.

A file can contain only one public class, and a public class must be in a file with a name that matches the class name. Your SwingApplet code needs to be in a file named SwingApplet.java.

What are you trying to do with a JFrame class and a JApplet class together anyways?


luck, db
There are no new questions, but there may be new answers.
dhuha al khoiri
Greenhorn

Joined: Apr 17, 2012
Posts: 24

i try to make swing applet,so i combine code from applet that i was learn before from my lecturer,and that code is JApplet class

and my code is Jframe,so i combined it, and hope can make a new code,that have a swing applet in it,is it right? or is it wrong?

so how come if i want to make an applet,but have a swing feature? i dunno


and about my habit,forgot to use code tags,i don't know to use it in this forum
where i can find codetags?and what button should i click? how i can make it,like you did?
explain it to me...

thanks,and sorry for my mistake,because i did'nt know to use code tags
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
A Java source file can have only one public class. You'll need to move that class to its own source file.
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

You need to create two java files:

SwingApplet.java
HelloWorldFrame.java

Since they don't appear to depend on each other from your code, compile and run separately.

WP
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4658
    
    5

dhuha al khoiri wrote:and about my habit,forgot to use code tags,i don't know to use it in this forum
where i can find codetags?and what button should i click? how i can make it,like you did?
explain it to me...

Maneesh gave you a link in the other thread I posted a link to here, but since you didn't see it there, I'll give it to you again: UseCodeTags <-- link
dhuha al khoiri
Greenhorn

Joined: Apr 17, 2012
Posts: 24
thanks for all of you,this forum so amazing!
you guys are really help me..

thank you so much,and if i have another question,i will ask again in this forum

God Bless You All...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help me,i can't fix this code