Solved

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

Posted on 2002-05-30
5
159 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

809 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