Solved

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

Posted on 2002-05-30
5
158 Views
Last Modified: 2010-03-31
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
Comment
Question by:fab1970
  • 3
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 7045797
You can access other applets using the AppletContext.

Applet other = applet.getAppletContext().getApplet(appletname);
0
 
LVL 92

Assisted Solution

by:objects
objects earned 250 total points
ID: 7046204
This article should help:

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

Let me know if you have any questions :)
0
 
LVL 2

Accepted Solution

by:
nir2002 earned 250 total points
ID: 7050546
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
 

Author Comment

by:fab1970
ID: 8724454
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
 
LVL 92

Expert Comment

by:objects
ID: 8725559
:-)

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
firstswap challenge 20 65
create a gui in perl 3 67
Java / Linux and Regular Expressions 11 67
even odd program using while loop 3 19
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now