Hello,
I have got a StartFrame-class that shows up a frame where a user can make
some selections
and when done with this another frame is opened from StartFrame-class for my
main-application.
I use StartFrame.hide() to make the first frame invisible. Later when the
user ends with the
main-application i want to close the main-frame and make the StartFrame
visible again.
How can i accomplish this? Besides, yes i know about modal-dialogs etc...
but i want to
have 2 independent frames.
Thanks in advance,
Jan
Andrew Thompson - 10 Mar 2004 10:44 GMT
On Wed, 10 Mar 2004 10:34:39 +0100, Jan Liße wrote:
Try this..
<code>
import java.awt.*;
import java.awt.event.*;
public class FramePairMain extends Frame implements ActionListener
{
Button b;
Frame child;
FramePairInitial fpi;
FramePairMain()
{
b = new Button("Close Main");
b.addActionListener(this);
add( b );
pack();
setLocation(50,50);
fpi = new FramePairInitial( this );
fpi.setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
setVisible(false);
fpi.setVisible(true);
dispose();
}
public static void main(String[] args)
{
FramePairMain fpm = new FramePairMain();
}
}
class FramePairInitial extends Frame implements ActionListener
{
Frame parent;
Button b;
FramePairInitial( Frame f )
{
parent =f;
b = new Button("Open Main");
b.addActionListener(this);
add( b );
pack();
}
public void actionPerformed(ActionEvent ae)
{
parent.setVisible(true);
setVisible(false);
}
}
</code>

Signature
Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology