Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

JFrame

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have designed a Java program using swing , such that while pressing a button in the main window , a JFrame window appears. Actually while closing the JFrame window, i want it alone to be closed. But while closing the JFrame window my main window also gets closed. How can i avoid this?

This is my coding.
 
Rancher
Posts: 3159
29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

while pressing a button in the main window , a JFrame window appears. Actually while closing the JFrame window, i want it alone to be closed.



Secondary windows should be JDialogs, not JFrames. The default behaviour for a JDialog is DISPOSE_ON_CLOSE, which will only close the dialog and not the parent JFrame.
 
Jysh Reey
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the response . But made JFrame to close itself alone..
 
Marshal
Posts: 68980
275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob C has pointed out the real error; you ought to correct that.
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at line 220. What are you telling the program to do there?
 
No matter. Try again. Fail again. Fail better. This time, do it with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic