Focus lost when I drag in an external file

How do I get the keyboard focus back to my Win App when it has been lost to a file explorer window?

setWantsKeyboardFocus(true);
&
grabKeyboardFocus();

Don’t work for me.
(Windows 10)

Can you please try to explain what are you doing.

Before you spend too long on this, bear in mind that most modern OSes deliberately prevent apps stealing the focus from a different process without the user actually clicking on your window.

toFront(true); on the main component has worked for me.

Are you dragging in or dragging out?

Anyway, I solved similar situations using the static method Process::makeForegroundProcess() (maybe in combination with Xenakios’ suggestion toFront())

HTH