This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about Closing the GUI / Shutting down the Server

 
Daniel Breitner
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Allan Cheong
Ranch Hand
Posts: 71
Eclipse IDE Java Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Roel De Nijs
Sheriff
Posts: 9157
76
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Daniel Breitner
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 9157
76
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic