• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about Closing the GUI / Shutting down the Server

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 71
Scala Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Have you no shame? Have you no decency? Have you no tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic