This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

is it a single thread or multiple thread for different jframe  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I have a JFrame (A) within main method and if I create another JFrame or JDialog (B) from an action event from a component wihin JFrame (A), then are A and B going to be two separate threads or are they running under the same thread.

Can anyone point me to any link or explain this kind of scenario...

Thanks.
 
Saloon Keeper
Posts: 10249
216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should all run under one thread, the Event Dispatch Thread. Essentially what happens is when you hit a button or some other action or event or whatever happens in Swing, it gets added to a queue of events which Swing needs to handle. The Event Dispatch Thread takes one of these events out of the queue at a time, and dispatches it, in other words, it performs the tasks associated with that event.
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All Swing components should be working on the same thread, the EDT, all listeners call their methods on the EDT. You will have to take care however if you do any background thread work in your app, and be sure that you abide by this rule when calling Swing methods or creating Swing components.
 
Marshal
Posts: 64496
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you open any Swing component's API it says

Warning: Swing is not thread safe. For more information see Swing's Threading Policy.

Read the link they provide.
 
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!