Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Dynamic resizing of JPanel

Reply
Thread Tools

Dynamic resizing of JPanel

 
 
Lobang Trader
Guest
Posts: n/a
 
      04-11-2004
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.

 
Reply With Quote
 
 
 
 
ak
Guest
Posts: n/a
 
      04-11-2004
> 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.


 
Reply With Quote
 
 
 
 
Babu Kalakrishnan
Guest
Posts: n/a
 
      04-12-2004

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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JPanel inside JPanel inside JFrame t1m1976 Java 1 11-07-2010 09:47 PM
[JPanel] Drop Down JPanel Raphael Jolivet Java 1 07-18-2008 12:30 AM
Add a JPanel to a JPanel... Andreas Beresko Java 6 07-16-2004 12:10 AM
Resizing my JPanel by startup does not work! Lars Schouw Java 4 10-28-2003 05:16 AM
Resizing a jpanel and the objects on it???????? steve smith Java 0 07-10-2003 06:22 PM



Advertisments