-1

Inside a JFrame class, I start one Thread. That thread checks something and return a boolean as true or false. Inside the JFrame class I want to check that boolean, and do actions according to the results of the thread. Now my question is how can I make my JFrame to wait untill the Thread ends?

How to make a program to sleep until my Thread ends ? I dont wanna to use Thread.join(). Is it possible?


I am interacting with the user in another window.

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
Paul Sigonoso
  • 575
  • 2
  • 5
  • 18
  • 1
    Your question is a bit vague -- what exactly do you mean by "thread checks something ...."? -- Are you interacting with the user in another window? If so, use a modal dialog. Are you running a background thread such as with a SwingWorker? If so, then use a PropertyChangeListener added to the SwingWorker and activate your GUI on completion. Please tell the details and show the pertinent code. Please improve your question. – Hovercraft Full Of Eels Aug 09 '16 at 01:40
  • I am interacting with the user in another window. – Paul Sigonoso Aug 09 '16 at 01:53
  • Then that "other window" should be a modal dialog. Please check out [this question](http://stackoverflow.com/questions/16367968/how-do-i-pause-a-jframe-while-another-is-running) for more on this, as well as [these questions](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=site:stackoverflow.com+java+pause+a+jframe+another+jframe) for a **lot** more on this. – Hovercraft Full Of Eels Aug 09 '16 at 01:54
  • If you need more specific help, then still improve this question. Please go through the [tour], the [help] and the [how to ask a good question](http://stackoverflow.com/help/how-to-ask) sections to see how this site works and to help you improve your current and future questions, which can help you get better answers. – Hovercraft Full Of Eels Aug 09 '16 at 01:55

1 Answers1

2

Make the second window a modal dialog such as either a JOptionPane or a modal JDialog. Either one will freeze the calling window until the dialog window is no longer visible. Please check out this question for more on this, as well as these questions for a lot more on this.

Community
  • 1
  • 1
Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373