Solved

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

Posted on 2002-05-30
5
157 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
:-)

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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

743 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

15 Experts available now in Live!

Get 1:1 Help Now