Dynamic resizing of JPanel

Discussion in 'Java' started by Lobang Trader, Apr 11, 2004.

  1. 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.
    Lobang Trader, Apr 11, 2004
    #1
    1. Advertising

  2. Lobang Trader

    ak Guest

    > 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.
    ak, Apr 11, 2004
    #2
    1. Advertising

  3. 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
    Babu Kalakrishnan, Apr 12, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. steve smith
    Replies:
    0
    Views:
    528
    steve smith
    Jul 10, 2003
  2. Lars Schouw
    Replies:
    4
    Views:
    800
    Lars Schouw
    Oct 28, 2003
  3. Andreas Beresko

    Add a JPanel to a JPanel...

    Andreas Beresko, Jul 14, 2004, in forum: Java
    Replies:
    6
    Views:
    26,968
  4. Raphael Jolivet

    [JPanel] Drop Down JPanel

    Raphael Jolivet, Jul 18, 2008, in forum: Java
    Replies:
    1
    Views:
    1,511
    John B. Matthews
    Jul 18, 2008
  5. t1m1976
    Replies:
    1
    Views:
    2,396
    t1m1976
    Nov 7, 2010
Loading...

Share This Page