aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes GUI not closing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GUI not closing" Watch "GUI not closing" New topic
Author

GUI not closing

James Eman
Ranch Hand

Joined: Mar 10, 2013
Posts: 45
ok so i wrote my GUI window and then a second one. so when the user clicks the button but when the user clicks the window stays open heres my code.

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2172
    
    7
Thats because you created 2 frames.

StartupWindow is a frame which you make visible when you create it.

Then in the constructor of StartupWindow you create a second JFrame.

StartupWindow should not be a frame because you didn't change the behaviour of a JFrame. So your code should be something like:



Once you do this your code won't compile because you are trying to reference methods of the StartupWindow wihich no longer exists.

So you need to change these methods to reference the frame you created. For example:



James Eman
Ranch Hand

Joined: Mar 10, 2013
Posts: 45
ok so i have this but it still dose not work i have this

Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

i hate to say it but your english is not very good.
ok so i wrote my GUI window and then a second one. so when the user clicks the button but when the user clicks the window stays open
means nothing to me.


SCJP
Visit my download page
James Eman
Ranch Hand

Joined: Mar 10, 2013
Posts: 45
there are a few different Gui's that do different things some times theirs a few open and other times i just need the main one on at some points but i can get my different GUI's to close. make more sense?
James Eman
Ranch Hand

Joined: Mar 10, 2013
Posts: 45
not tying to be a annoyance on the forums but im trying to learn GUIs so some help would be nice. i build this program that has some clicks that go to diffrent questions but when i call the new windows the old one dose not close.
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2233
    
  47
Sorry but it's hard for people to help you if you don't clearly explain what your code is supposed to do and what it is actually doing.

I've had a quick look at your code and a problem I can see is (and I've no idea if it's the one causing your problem because like Rob I'm unclear as to what the issue is), in the actionPerformed() method you are creating a new JFrame and overwriting the value in jf and so any future calls to jf's methods will be on the new instance and not the instance that is currently displayed.
James Eman
Ranch Hand

Joined: Mar 10, 2013
Posts: 45
ok yea that works thank you. thank you again
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2233
    
  47
My pleasure.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GUI not closing