hi,
you could do something like this:
public static void main(String[] args){
...
ToBeShared shared = ...
YourJFrame1 jframe1 = new YourJFrame(..., shared);
YourJFrame2 jframe2 = new YourJFrame(..., shared);
Doing so, both 1 && 2 will be able to access to 'shared' variable. Beware that doing so you could introduce some concurrent programming problems that could lead to errors due to an incorrect synchronization of accesses to 'shared' variable.?br>
JoYiCk
Thanks for replies.
How can I pass it through a costructor?
String a="X";
JFrame jframe1=new JFrame(a);
jframe1.setVisible(true);
I got error warning "can not find symbol"
How to solve this?
I also have try as JoYiCk post
there is an error that "Can not find symbol; class shared"
Can you help me a little more?
Thanks a lot
You write your own class that extends JFrame.
class MyFrame extends JFrame {
MyFrame otherFrame;
MyFrame() {
//default constructor
}
MyFrame(MyFrame mf) {
otherFrame = mf;
}
public void someMethod() {
String s = otherFrame.getWhatINeed();
}
public String getWhatINeed() {
return whatYouNeed;
}
}