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...
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.
The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
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.