Link to home
Start Free TrialLog in
Avatar of epaga
epaga

asked on

How to modify JInternalFrame's iconfying behaviour?

Hi there!
I have a JInternalFrame which I'd like to basically shrink in size when you click on the iconify icon, but not to become an icon. I have set up a listener for iconified, in which I basically first de-iconify, then set the size:

                public void internalFrameIconified(InternalFrameEvent e) {
                    try {
                        vt.setIcon(false);
                    }
                    catch (Exception exc) {}
                    if (oldHeight == 0) {
                          oldHeight = vt.getHeight();
                          vt.setSize(vt.getWidth(),26);
                      }
                    else {
                        vt.setSize(vt.getWidth(),oldHeight);
                        oldHeight = 0;
                    }

                }

This works rather nicely - the problem is just that the iconify icon stays the same - so even when it's "minimized", the iconify button is still there as "minimize".

Is there either a way to change that iconify icon without actually iconifying the window? My problem is that I'm connecting the various windows with lines, so if I iconify one, I get problems if I do more than just set its size.

Thanks ahead of time for any help...
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> the iconify icon stays the same - so even when it's "minimized"
yeah, because the internal frame IS NOT minimized: it's made very small (<> minimized)

So in fact, you're aksing for a method to adapt the minimize/maximize icons...
Mmm... could be difficult. If not impossible, because I guess that's the OS's business.
Avatar of epaga
epaga

ASKER

how and where is that "iconify / maximize" button set? Is there no way to manually switch between the two or something?

PRoviding a custom UI implementation and painting the title bar myself...uh...that sounds a bit complicated. Is it? :-)
> ..uh...that sounds a bit complicated. Is it? :-)

not relly, no different than laying out any container really.
>> Is there no way to manually switch between the two or something?
I'm afraid not. That icon "follows" the internal frame's state.
That's what 99,99% of the people expect ;°)
>> My problem is that I'm connecting the various windows with lines, so if I iconify one, I get problems if I do more than just set its size
What kind of problems?
Maybe you have to rethink this part...
Avatar of epaga

ASKER

Well, in the end I just had to give up on the iconify button - I now have a context menu "Minimize" and "Restore" respectively, and a double click on the title bar minimizes and restores the window.
The problems i was having, btw, was that the lines lost their reference to the actual frame, since it became hidden, and the icon displayed instead was a different reference.

So, there isn't really a solution to the question, and the first correct answer was from objects. :)