• Post Reply Bookmark Topic Watch Topic
  • New Topic

Closing an inner frame

 
jonas okwara
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My entire application closes when I click the cancel button on a gui launched by an inner class. This is not the intended result. I only want the specific frame to exit leaving the main Application

Can anyone help me out of this.



Thx
java newbie
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code? I could make a bunch of assumptions as to your problem, but it would be more beneficial to the both of us if we could see the relivent code. I guess my first question without seeing the code is, what cancel button are you talking about?
 
jonas okwara
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if (actCmd.equals("Cancel")){
System.exit(0);
}


This is the code. This is all within an ActionListener method declaration.
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Call dispose on the container that you launched and want to close.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.exit(0) will actually tell the VM to die. If that happens every bit of your application closes. Do what Craig said and call dispose() on the JFrame you want to close.

Perhaps going through Sun's Swing Tutorial would benifit you. There is a lot of basic information and helpful examples that solve simple beginner issues. When I was learning I used it. In fact, I go back to it whenever I code a lot of Models because I tend to forget how to code those for JTables and JLists, etc. It's always a good refresher.

Also, get to know the API, or rather, know how to use it. It's invaluable.
 
jonas okwara
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
awesome !!


Thx

jonas
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!