• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

working with swing Threads

 
Mohamed Iqzas
Ranch Hand
Posts: 72
Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a swing application. from a Jbutton actionListener i'm creating a JDialog for user inputs. Now I want the button's action Listener to proceed only after getting inputs from the user.

Please help me how to do this? I tried calling wait on thread of first actionListener, but it seems both the action listeners are in same thread, so blocking the first one blocks the other also.

Please refer the below code: (I'm not sure whether it qualifies as an SSCCE )

 
Chris Hurst
Ranch Hand
Posts: 443
3
C++ Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your right the two threads your code is trying to communicate with are both the one and only EDT thread ...

Either try a modal dialog so you don't need the communication (wait/notify), in which case post this on the swing forum.

Or why not do whatever you where going to do on the button actionlistener in your popup dialog.

If you really want to solve this with threads you need to get your wait off the EDT so create a new thread which waits on the dialog on the EDT and then presumably will have to SwingUtilities.invokeLater back onto the EDT when finished ;-)
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic