Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

Two classes: one read datas from the other: how to?

I have web page with frames.
in the "main" frame i have an applet that open a socket with the server and load a whole of datas, storing it in an Int[4][400] variable.

In the other frame i can sometimes have another class, that needs to work with this array.

So i need a way to read the array from the "main" applet.

i've tryed with a function "getMyArray" in the main applet that return the array, and a call to

MyArray=main.getMyArray();

in the "secondary" applet, but this method works only if the secondary applet starts the main (that i can't accept).

How can i obtain variables from another class?
0
fab1970
Asked:
fab1970
  • 3
2 Solutions
 
objectsCommented:
You can access other applets using the AppletContext.

Applet other = applet.getAppletContext().getApplet(appletname);
0
 
objectsCommented:
This article should help:

http://www.javaworld.com/javaworld/javatips/jw-javatip101.html

Let me know if you have any questions :)
0
 
nir2002Commented:
This solution is base on one VM:
declare the method getMyArray() as static at the first applet.
At the other applet call <firstAplletClassName>.getMyArray()
and use the array.

The link objects show you is using this idea.
hope it help :-)
0
 
fab1970Author Commented:
i'm really sorry...i can't remeber what was the right solution... so i will split the points, giving us the maximum amount possible.
0
 
objectsCommented:
:-)

http://www.evalu8.com.au
"Giving everyone a voice"
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now