Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JDialog with no Option buttons  RSS feed

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am needing to know if there is a way to create a JOPtionPane or Dialog window that does not have any options for closing the window that I can close from within the program itself. I need a way of pausing the entire app for a period of time.

------------------
Happy Coding,
Gregg Bolinger
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's some example code I made to illustrate this concept :



One thing to watch out for when doing this... I noticed if I set the waitDialog visible before I started the thread, the thread would not run. If I set the waitDialog visible in the beginning of the run method, the rest of the thread would not run... This only happened when the waitDialog was modal, though... I guess one of the side effects of a modal dialog is that it suspends the thread it is executing in...

-Nate
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey thanks!! Can't you still close the Dialog Box though? Or is it stuck in the thread. Actually here is what I need to do.
I have a client to server to client game, and I would like a player to be able to pause the game, so on one side, the player pauses and can unpause, but on the other side, I need to freeze him completely.
Have any ideas?
------------------
Happy Coding,
Gregg Bolinger
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can you close the dialog in the program I posted above? It's modal and the exit button in the corner doesn't do anything... From what you described, it sounds like you need 2 modal dialogs... one with an "un-Pause" button and one without... When one player pauses, send a message to the other users program to pop up a pause dialog without an "un-Pause" button. Have a thread like the one above, but change it to loop until it recieves the message to unpause, and then call setVisible( false ) on the dialog box when it exits the loop... When the other user gets back and clicks "un-Pause", close the dialog and send a message to the other user to un-pause theirs also...

-Nate
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!