This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Hi I would like to open a chm file from my "help" menu. I got two problem related to that: 1.The first time the menu is clicked i start the process and the help is opened on top of my application frame. but - the second time It is opened - the only wat to recognize i sthe process is still active is to call exitValue (if it get an exception - process is still active) but - how can i make the frame on top of my application frame( the current active frame) 2.when the application is closed the help application does not "die" with the rest of the application. I will be happy to get some ideas of how can i control it. this is my code:
The second issue you mentioned about the process not dying along with your Java process can be overcome by manually killing the process in your exit code.
I find it's always good practice to have a handle available on the windowClosing event of your GUI. You don't have to put any special code inside this event capture block but it means that you can tidy things up ni the event of your Java app closing.
I always create an internal class which handles these Window events and then add an instance of the internal class as a registered listener for the parent class.
The code isn't perfect, it's been a long time since I worked with Java and I'm a little rusty!
With regards to your second problem I'm not 100% sure what the actual problem you feel that you have is. There is nothing wrong with using an exception to handle a certain situation. In fact that is why they exist.
An alternative would be to create a new Thread and pass it a Runnable object which spawns the external help file viewer. The runnable object can then be monitored to see if it is still running or not.
Sometimes though, it's just easier and cleaner to wait for an exception liek the one you get already and then deal with things as appropriate.
Hope some of this helps,
Joined: Sep 17, 2003
hi first of all thatks for trying to help. I guess my description is not too clear: the problem of closing the process - i do have the windowAdapter -and i kill the process.destroy -without any affection. the other problem is if the help application is already open but minimized - i can recognize that the process is active but i cant make it "jump" to the top of the screen (so it will be the active frame).
About the way i detact that the process is active - lets just admit that a better way was to ask the process "isActive()" or soemthing like that and not to get the exception saying the process was not over yet.....