AWT dispatch thread

The method DockController.setFocusedDockable() has the following code:

if( EventQueue.isDispatchThread() ){
   SwingUtilities.invokeLater( new Runnable(){
     public void run() {
         ensureFocusSet();     
     }
   });
}
else{
   // we are in the wrong Thread, but we can try...
   ensureFocusSet();
}

I think that should be:

if (EventQueue.isDispatchThread())
   ensureFocusSet();
else
{
 SwingUtilities.invokeLater(new Runnable()
 {
     public void run() 
     {
         ensureFocusSet();     
     }
 });
}

Peter

No, that was deliberately.

The actions that lead to a focus change in DF (i.e. ending a drag & drop operation) normally happen in the EDT. Unfortunately most of these actions involve events (i.e. a MouseEvent “mousePressed”) that lead automatically to a focus change.

Since the focus system handles multiple requests at the same time really bad, the call to invokeLater ensures that our focus request gets dispatched when the queue is already empty - and thus our request gets granted and not overridden.

OK, I understand.

Maybe you should put this explaination in the code :smiley:

Peter

I didn’t expect anyone reading my code… :eek: