Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / March 2004

Tip: Looking for answers? Try searching our database.

Flipping between frames?

Thread view: 
Jan Li?e - 10 Mar 2004 09:34 GMT
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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.