Results 1 to 2 of 2
  1. #1
    fam2315 is offline Member
    Join Date
    Feb 2011
    Posts
    78
    Rep Power
    0

    Default JPanel expanding

    I have a JPanel that is setup to a BoxLayout(Call it PanelA), that is inside of a JScrollPane.

    I am adding multiple JPanels to PanelA inside the code(not the Netbeans Designer). Each of these JPanels contains a JTable. How can I get the JPanels to be large enough to hold all the rows in the jtable?

    They keep defaulting to a size capable of displaying 25 rows. I know the Jtables are more than 25 rows because if I show the scrollbar for the individual tables, it scrolls down(maybe 100 more rows). So how can I get the JPanels that I am adding to automatically size large enough to display all the rows(without having to scroll)?

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,226
    Rep Power
    6

    Default Re: JPanel expanding

    I assume you are adding the tables to a scrollpane and then you add the scrollpane to the panel. Then, to prevent scrollbars from appearing you need to do:

    Java Code:
    table.setPreferredScrollableViewportSize(table.getPreferredSize());

Similar Threads

  1. JPanel shrinking-expanding problem
    By eLancaster in forum New To Java
    Replies: 4
    Last Post: 04-14-2011, 05:48 PM
  2. JTree not expanding?
    By captain alge in forum New To Java
    Replies: 1
    Last Post: 04-14-2011, 04:27 PM
  3. text areas expanding
    By aizen92 in forum New To Java
    Replies: 5
    Last Post: 03-20-2011, 08:51 PM
  4. JFrame expanding to fit content
    By pcman312 in forum AWT / Swing
    Replies: 1
    Last Post: 12-31-2010, 07:09 PM
  5. dynamically expanding byte container?
    By dfens in forum New To Java
    Replies: 1
    Last Post: 07-03-2009, 10:27 AM

Posting Permissions

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