Focus on JInternalFrame

I have been unable to give focus to a JInternalFrame no matter what I do.  Perhaps I'm missing something, but even calling setFocusOwner(jif) doesn't do any good.  Can someone recommend a way to do this?


I may be missing something, but dont you implement a focuslistener, then ahve a method something like :-

private void setFocus() {
      canvas.addFocusListener(new FocusListener() {
         public void focusGained(FocusEvent e) {
         public void focusLost(FocusEvent e) {

I don't think you understand my problem.  I want to give the JInternalFrame focus.  I want the top of the frame to highlight focused instead of keep the "blurred" color.  I can give items focus inside the JInternalFrame but the JInternalFrame still does not receive focus like it should.  However, if I use the mouse to click on the JInternalFrame or in one of the fields the JInternalFrame receives focus like it should.  I need a programmatic way of activating the JInternalFrame.


Simply do a setSelected( true ) on the internal frame  :slight_smile:

But I have added this to setFocusOwner, too, to get the expected behaviour.

Great, thanks buddy. :wink: