Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2009
    Posts
    7
    Rep Power
    0

    Default Expandable Grid Panel

    Hi guys,

    I'm looking to create a JPanel with a GridLayout, except I want to control-click one of the grid cells in the panel and have it expand to fill the entire panel (then when I do the same again, it should return to the grid view). I can see me having to create a custom layout/control, but I just wondered if anybody has done this type of thing before?

    Thanks, Lee.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    It can be done probably in several ways. One is to put all the grid panels in a JPanel that uses GridLayout, then add this to a main JPanel that uses borderlayout. When a grid panel is clicked swap the gridlayoutpanel for the single panel and call revalidate and repaint. Then if ctrl-clicked again, remove all from the gridlayout panel and then re-add the panels (don't do this and it will have a gap due to the panel that was removed from the grid and shown in the main panel). Then add the gridlayout panel to the main panel, borderlayout.center, and again revalidate and repaint.

    Play with it, and you'll likely get it to work out.

  3. #3
    Join Date
    Aug 2009
    Posts
    7
    Rep Power
    0

    Default

    Thankyou Fubarable, looks like great minds think alike! I coded a solution yesterday and that's exactly what I did! :D

Similar Threads

  1. Database Grid
    By leoleo4614 in forum AWT / Swing
    Replies: 1
    Last Post: 12-13-2008, 07:02 AM
  2. How do i place objects onto a grid?
    By Nakira in forum New To Java
    Replies: 7
    Last Post: 11-14-2008, 06:49 PM
  3. [SOLVED] How to create a Grid?
    By Nakira in forum New To Java
    Replies: 11
    Last Post: 11-12-2008, 10:45 AM
  4. how to get the grid values
    By jazz2k8 in forum Advanced Java
    Replies: 2
    Last Post: 11-06-2008, 02:11 PM
  5. Help with Grid Layout
    By coco in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 08:03 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •