Ernest,
Im stil not sure how to implement ur suggestion. Wat I hav now is actually 3 classes. The 1st class is simply a Frame that closes. The second one is a Frame that closes but with a button that changes the value of its int variable x and also contains the public method "getX()" which supposedly returns the new value of x to its caller. The 3rd class merely contains the main method and instantiates both the 1st and second classes thus:
class MainClass implements ActionListener {
static Button bshow = new Button("Show Window");
static Button getEks = new Button("Get X");
public static void main (
String args []) {
FrameUClose win1 = new FrameUClose("This window closes.");
win1.setLayout(new FlowLayout());
win1.add(bshow); win1.add(getEks);
win1.setSize(400,400);
win1.setVisible(true);
bshow.addActionListener(new RealWindow());
getEks.addActionListener(new RealWindow());
}
public void actionPerformed(ActionEvent e) {
ButtonFrame win2 = new ButtonFrame();
if (e.getSource() == bshow) {
win2.setLayout(new FlowLayout());
win2.setSize(200,200);
win2.setVisible(true);
}
else if (e.getSource() == getEks) {
System.out.println("x = " + win2.getX());
}
}
}
You see above how I called the method getX() of the win2 object to try to display the value of x. This is obviously wrong. How can I display the new value of x correctly?
Jeff