I need the iconable/minimize feature of JInternalFrame to collapse the frame (which it does), but also maintain the JInternalFrame’s position within its parent component. Currently, when I press the minimize button of a JInternalFrame, java places the component at the bottom of its container. Is there a way to maintain the location whilst minimizing? If there is no obvious solution, how might I observe the iconable icon and remove the default listener? Thank you.
I need the iconable/minimize feature of JInternalFrame to collapse the frame (which it does),
Share
To modify this behavior you would want to create an implementation of
javax.swing.DesktopManager. To get the majority of the default behavior already available I’d suggest subclassingjavax.swing.DefaultDesktopManager.In DefaultDesktopManager the method
iconifyFrame(JInternalFrame f)controls the complete behavior but internally uses the methodprotected Rectangle getBoundsForIconOf(JInternalFrame f)to determine the bounds for the icon of the frame being minimized. Here you can return the bounds for the icon of the internal frame that you’d like to use. The problem is those values are cached so if you want it to move every time you would need to do something like the following.