Dynamic resizing of JPanel  
Author Message
Lobang Trader





PostPosted: 2004-4-11 19:30:00 Top

java-programmer, Dynamic resizing of JPanel Dear experts,

I have the a JDesktopPane and a JPanel added to the CENTER and SOUTH
position of a JFrame respectively.

I would like to dynamically resize the JPanel upon mouseExited like the
Windows TaskBar.

On mouseExited of the JPanel i set the bounds of the JPanel to a new
size. However, the sizes do not reflect visually. I have called
invalidate(), validate(), repaint() and none seems to work.

Other than using JSplitPane to create a resizable JPanel, how can I make
this work?

Others have suggested using LayoutManagers but which one and how?

Thank you in advance.

 
ak





PostPosted: 2004-4-11 22:55:00 Top

java-programmer >> Dynamic resizing of JPanel > I have the a JDesktopPane and a JPanel added to the CENTER and SOUTH
> position of a JFrame respectively.
>
> I would like to dynamically resize the JPanel upon mouseExited like the
> Windows TaskBar.

seems that you need JSplitPanel

____________

http://reader.imagero.com the best java image reader.


 
Babu Kalakrishnan





PostPosted: 2004-4-12 19:14:00 Top

java-programmer >> Dynamic resizing of JPanel
Followups set to c.l.j.gui.

Lobang Trader wrote:
> Dear experts,
>
> I have the a JDesktopPane and a JPanel added to the CENTER and SOUTH
> position of a JFrame respectively.
>
> I would like to dynamically resize the JPanel upon mouseExited like the
> Windows TaskBar.
>
> On mouseExited of the JPanel i set the bounds of the JPanel to a new
> size. However, the sizes do not reflect visually. I have called
> invalidate(), validate(), repaint() and none seems to work.
>

Setting the bounds of a panel will not help because the moment it is
revalidated, its size will again be set to the preferred value (only the height
actually since it is the SOUTH component of a BorderLayout) by the
LayoutManager.

Override the getPreferredSize method of the JPanel to return a different
value based on a flag. Set / reset the flag in the mouseExited/Entered events
and revalidate the container.

e.g.

private boolean minimized = false;

public Dimension getPreferredSize()
{
Dimension pref = super.getPreferredSize();
if (minimized) pref.height = 5;
return pref;
}

BK