Results 1 to 9 of 9
Like Tree5Likes
  • 1 Post By KevinWorkman
  • 1 Post By KevinWorkman
  • 1 Post By KevinWorkman
  • 2 Post By jim829

Thread: JApplet

  1. #1
    faraa is offline Member
    Join Date
    Mar 2013
    Posts
    70
    Rep Power
    0

    Default JApplet

    Hi
    In a project I have several classes and one of them is JApplet.How can I call methods that are in this class,in other classes?
    Why I can't use these?
    clas A extends JApplet{c()}

    JApplet p;
    p.c();

    or

    A a;
    a.c();

    Thank's

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,690
    Rep Power
    8

    Default Re: JApplet

    Pass in a reference to an instance of the first class, either by a constructor or setter.
    faraa likes this.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    faraa is offline Member
    Join Date
    Mar 2013
    Posts
    70
    Rep Power
    0

    Default Re: JApplet

    Thank you
    I did it .But it doesn't work.
    I don't understand why it doesn't work.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,690
    Rep Power
    8

    Default Re: JApplet

    For more specific help, you're going to have to post an SSCCE that demonstrates the flow of the program (note: NOT the whole program!) so we understand exactly what you're trying to do.
    faraa likes this.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    faraa is offline Member
    Join Date
    Mar 2013
    Posts
    70
    Rep Power
    0

    Default Re: JApplet

    Java Code:
    public class ScreenManager {
    TankCity tc;
     public ScreenManager(TankCity tc){
    this.tc=tc;
    }
    public void conflict() throws NullPointerException{
    try {
                 for (int j = 0; j < ets.size(); j++) {
                for (int i = 0; i < buls.size(); i++) {
                    EnemyTank e = ets.get(j);
                        Bullet b = buls.get(i);
                       
                        if ((b.x == e.x  && b.y + b.h / 2 > e.y + e.h / 2 && b.y + b.h / 2 < e.y + e.h)
     tc.createTank(e);//createTank is defined in TankCity class
    }
    }

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,690
    Rep Power
    8

    Default Re: JApplet

    What does this code do? Does it work? If not, what doesn't work about it? Note that this isn't an SSCCE, so it's hard to be more specific.
    faraa likes this.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    2,924
    Rep Power
    4

    Default Re: JApplet

    Folks have replied to two of your previous posts with apparently no resolution. That does not help those who search this forum nor is it going to encourage others to reply to your questions.

    ArrayList
    rotating image

    Regards,
    Jim
    DarrylBurke and faraa like this.
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  8. #8
    faraa is offline Member
    Join Date
    Mar 2013
    Posts
    70
    Rep Power
    0

    Default Re: JApplet

    Yes.You're right.I'm really sorry.
    In two other posts that you said I have mistakes that after a few time I understood them.
    and I forgot to say that my problem is resolved
    Excuse me again...and thank's

  9. #9
    faraa is offline Member
    Join Date
    Mar 2013
    Posts
    70
    Rep Power
    0

    Default Re: JApplet

    KevinWorkman:
    Sorry,I really don't know How to post SSCCE.And I'm really sorry.
    Fortunately I resolved that problem and thank you again....

Similar Threads

  1. JOptionPane to JApplet
    By alphablitzer in forum New To Java
    Replies: 1
    Last Post: 05-31-2013, 10:26 AM
  2. japplet question
    By jobud9 in forum New To Java
    Replies: 1
    Last Post: 12-20-2011, 02:14 AM
  3. JApplet on MAC
    By ld_pvl in forum Java Applets
    Replies: 0
    Last Post: 08-23-2009, 01:40 PM
  4. How to set permissions for a JApplet
    By Gatts79 in forum Java Applets
    Replies: 2
    Last Post: 08-12-2009, 01:54 PM
  5. JFrame to JApplet or JApplet to JApplet
    By ramesh.8189 in forum AWT / Swing
    Replies: 13
    Last Post: 02-08-2009, 06:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •