Jump to content

  • Log In with Google      Sign In   
  • Create Account


[java] Classess can access Applet variables??


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 jamesweston29   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 June 2000 - 10:44 PM

Hi I was wordering if a custom class can access the variables of the applet. ie If I create a class such as class Player { int xPos; int YPos; }; Can I access the "global" valraibles of the main applet. I would appreciate any help. Thanx

Sponsor:

#2 Icculus   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 June 2000 - 10:52 PM

If this class is a inner class it can automatically, or sometimes you might have to use this syntax to access a outer classes variables from a inner class. Say
OuterClassName.this.variableName

Another way to do it without inner classes is to pass a pointer or a refrence to the applet in.
class Player
{
int xPos;
int yPos;
JApplet applet;


public Player(JApplet applet)
{
this.applet = applet;//now you have access through applet

}
}





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS