The Artima Developer Community
Sponsored Link

Java Answers Forum
Swing

1 reply on 1 page. Most recent reply: Jan 8, 2004 6:23 AM by mausam

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
jainendra

Posts: 2
Nickname: jksingh
Registered: Jan, 2004

Swing Posted: Jan 7, 2004 5:11 AM
Reply to this message Reply
Advertisement
As i am opening a frame window on button click .So the problem is that every time i click Button its open a new frame but what i want to open only one frame at a time that means deactivate or close first window than activate second window.
jainendra@netedgecomputing.com


mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: Swing Posted: Jan 8, 2004 6:23 AM
Reply to this message Reply
How abt doing this??

Make the instance of ur frame a class level variable in the class which have ur button.

Now in the action performed event of the button check if the frame is avaliable/visible/ if yes dispose and create another instance of the frame and show.
the class might look like

class Sample{

Frame classFrame = null;

Sample()
{
//ok button and all stuff
}

public void okButtonActionPerformed()
{
if (classFrame == null)
{
classFrame = new Frame() ; //and all such stuff
}
else
{
if (classFrame.isVisible()) //and other check
{
classFrame.dispose();//and all such stuff
}
}
}
}


HTH

Flat View: This topic has 1 reply on 1 page
Topic: string manipulations Previous Topic   Next Topic Topic: invoke windows api(i.e:-pdf/doc/ppt exe)

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use