• Post Reply Bookmark Topic Watch Topic
  • New Topic

multi class gui

 
Tim Berden
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello to all. New to Java here.

What I have here is a simple text editor with a menu bar containing as follows: File Edit Tools Help. ScratchPad is the name of my text editor class.

Everything is working to my liking thus far. I have created a class called Help containing another form that will allow the user to navigate through some simple help topics (effectively a help window).

When I run the text editor, and bring up the Help class from the help menu everything is great. The problem is when I try to close the Help window, it completely closes my whole project, text editor and all.

Is there some event that could handle a close button that would just close the Help window? System.exit(0) closes the entire project.

Thanks to all who read this!

Tim Berden
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sounds like your help window is a JFrame with
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

remove that line, or better yet (generally better), make the help window
a JDialog instead of a JFrame
1) a dialog won't put a 2nd icon in the task bar
2) the dailog can be modal - meaning the window has to close to re-enable access to the main window
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Michael except I just wouldn't make the dialog modal. From a UXP perspective users like to bounce between the help window and the application so as to follow along with the instructions.

Making the dialog modal the user would have to close the dialog, try again, and if were still having a problem, open the help dialog again, losing access to the application.

Just my 2 cents
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!