• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help me,i can't fix this code

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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


 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you going to tell us what the problem with this code is, or are we supposed to guess?
 
Ranch Hand
Posts: 251
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
without knowing how we will give you answers?
 
dhuha al khoiri
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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...
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
dhuha al khoiri
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A Java source file can have only one public class. You'll need to move that class to its own source file.
 
Ranch Hand
Posts: 859
IBM DB2 Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
reply
    Bookmark Topic Watch Topic
  • New Topic