| Author |
Question about Closing the GUI / Shutting down the Server
|
Daniel Breitner
Ranch Hand
Joined: Nov 13, 2008
Posts: 70
|
|
Hi everyone,
Just two quick questions on GUI Listeners:
1) About closing the GUI
I want to make sure, that however the User quits the GUI, a certain method is being called. I have no problem in using this with Buttons or JMenuEntries ... but how do I tell the window to run the method when the User clicks the "X" (window close button) ?
2) About RMI when closing the Server
Is it necessary to run "Naming.unbind..." when the Server is shutting down or is it ok, just to use System.ecit(0) and a shutdown hook at the datafile ?
with kind regards
daniel
|
Visit me at http://liferay-blogging.blogspot.com
|
 |
Allan Cheong
Ranch Hand
Joined: Nov 12, 2009
Posts: 68
|
|
Funny you should mention question number 1. I just finished this part today. Your frame must implement the method
protected void processWindowEvent(WindowEvent e);
Edit: @Roel: Oops sorry.
|
SCJP6, SCJD, SCWCD5
Perspective
Freaky Codes
|
 |
Roel De Nijs
Bartender
Joined: Jul 19, 2004
Posts: 4349
|
|
Hi Daniel,
I just used System.exit(0); to stop my server, no call to unbind. I did use a shutdownhook, because I use a record cache, so it's really important to write cache back to file
@Allan: Don't just quote complete posts from others. It has no added value at all and just wastes disk space. Use quotes wisely!
Kind regards,
Roel
|
SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
|
 |
Daniel Breitner
Ranch Hand
Joined: Nov 13, 2008
Posts: 70
|
|
Ok, After I realized that my shutdownHook making sure the datafile is properly close is enough, I just added listeners to my JMenuBar enabling it to quit my application.
One question is going around in my mind ...
I implemented it, but I don´t know if it´s necessary:
Is it necessary to let the User choose a port to start the server on ?
|
 |
Roel De Nijs
Bartender
Joined: Jul 19, 2004
Posts: 4349
|
|
Daniel Breitner wrote:Is it necessary to let the User choose a port to start the server on ?
That's actually a good question, because nothing is said about it in the requirements So it is certainly not a must requirement, so you are not required to do it. Although I think it's better (more user-friendly) to add the possibility to run on another port. Because what would happen if the port you use in your program (default rmi or an arbitrary chosen value) is already in use.
Kind regards,
Roel
|
 |
 |
|
|
subject: Question about Closing the GUI / Shutting down the Server
|
|
|