Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help and Question on JOptionPane Message  RSS feed

 
Leo Leong
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there, I am current doing a project on a small java website on myself and I making a session timeout where user can login to the web and use the web for some period of time. After that period time is up, a message will popup and ask the user if they want to extend their time if user chooses yes then the program will extend the time to let the user use, else it will logout. So i would like to ask if the JOptionPane warning message able to make this function where if the user didn't select both of the chooses and stay there for quite a while i would like it to auto make the JOptionPane to close by itself and logout from the web. Can anyone help and if so any example i can refer to? Thank you
 
Rob Camick
Ranch Hand
Posts: 2800
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the JOptionPane API where you will find a section on the "Direct Use" of an option pane. This approach gives you access to the dialog itself. So now before the dialog is displayed you can start a Swing Timer which you schedule to fire after an elapsed time. When the user responsds you stop the Timer. If the Timer fires, then the user hasn't responsed so you can close the dialog and then do you logout processing.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!