Results 1 to 5 of 5
  1. #1
    hsl
    hsl is offline Member
    Join Date
    May 2012
    Posts
    3
    Rep Power
    0

    Question Using methods from AppletContext interface..

    So I was writing an applet where I had to use the getApplet() method. The applet works fine but I have a doubt. All the methods in the AppletContext are abstract. So how is it possible to write the following piece of code..

    AppletContext context=this.getAppletContext();
    MyApplet=(MyApplet)context.getApplet("applet_name" );

    PS - I know and understand inheritance. And I know that the body of the getApplet() method has to be written in some class that implements AppletContext. I have researched a lot but I can't seem to find it.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,038
    Blog Entries
    7
    Rep Power
    23

    Default Re: Using methods from AppletContext interface..

    The getAppletContext() method gives you another class that extends the abstract class AbstractContext. That other class has all the mentioned methods implemented.

    kind regards,

    Jos
    I have the stamina of a seal; I lie on the beach instead of running on it.

  3. #3
    hsl
    hsl is offline Member
    Join Date
    May 2012
    Posts
    3
    Rep Power
    0

    Default Re: Using methods from AppletContext interface..

    So getAppletContext() method which has a return type of AppletContext actually returns a reference of type AppletContext that refers to some other object which implements AppletContext. Can you tell me what type this object is? Also can you tell me if I can see the actual body of the getAppletContext() and getApplet(), wherever they are written?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    27

    Default Re: Using methods from AppletContext interface..

    Quote Originally Posted by hsl View Post
    So getAppletContext() method which has a return type of AppletContext actually returns a reference of type AppletContext that refers to some other object which implements AppletContext. Can you tell me what type this object is? Also can you tell me if I can see the actual body of the getAppletContext() and getApplet(), wherever they are written?
    Java Code:
    import java.applet.AppletContext;
    import javax.swing.JApplet;
    
    public class AppletEg extends JApplet {
       @Override
       public void init() {
          AppletContext foo = getAppletContext();
          System.out.println(foo.getClass().getName());
       }
    }
    Then see what is returned.

    You might find the code for this in the source zip file.

  5. #5
    hsl
    hsl is offline Member
    Join Date
    May 2012
    Posts
    3
    Rep Power
    0

    Default Re: Using methods from AppletContext interface..

    Thanks a bunch

Similar Threads

  1. Interface methods
    By DeltaWarrior in forum New To Java
    Replies: 3
    Last Post: 12-26-2011, 01:48 PM
  2. Replies: 0
    Last Post: 10-17-2011, 05:48 PM
  3. how to call or use methods inside interface?
    By akhmad in forum New To Java
    Replies: 2
    Last Post: 11-10-2010, 10:55 AM
  4. Methods that are NOT defined in interface
    By johto760 in forum New To Java
    Replies: 7
    Last Post: 10-29-2010, 06:31 PM
  5. Why methods in an interface cannot be static?
    By cbalu in forum Advanced Java
    Replies: 2
    Last Post: 12-12-2007, 08:57 PM

Tags for this Thread

Posting Permissions

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