JDesktopPane - how to get active frame

Dariusz G. Jagielski picture Dariusz G. Jagielski · Dec 17, 2011 · Viewed 8.8k times · Source

How to get active (having focus) frame (JInternalFrame) that is inside JDesktopPane? I need it for my MDI notepad (not that anybody would use that, just a training project). Looking at api, I see only functions to get all JInternalFrames, not active one.

Answer

kv-prajapati picture kv-prajapati · Dec 17, 2011

Use JDekstopPane.getSelectedFrame() method (From doc: currently active JInternalFrame in this JDesktopPane, or null if no JInternalFrame is currently active.) or JDesktopPane.getAllFrames() to get list of all JInternalFrames currently displayed in the desktop and check isSelected() method.