Solved

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

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
difference between sorce folder and folder in eclipise 3 40
SequenceInputStream example 3 21
Java basic valueOf question 1 32
Java array sort 10 26
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

679 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