Results 1 to 4 of 4

Thread: Size of JTable

  1. #1
    andre1011 is offline Member
    Join Date
    Feb 2009
    Location
    Sacramento CA
    Posts
    17
    Rep Power
    0

    Default Size of JTable

    Hello could any one tell me how to set the size of a JTable?
    Could you tell me what controls the size of a JTable?

  2. #2
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    The TableModel controls the size. The API documentation has an example.

  3. #3
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    You can use the setPreferredSize method. For scrollPane sizing I often use something like
    Java Code:
    Dimension d = table.getPreferredSize();
    // Make changes to [i]d[/i] if you like...
    table.setPreferredScrollableViewportSize(d);

  4. #4
    andre1011 is offline Member
    Join Date
    Feb 2009
    Location
    Sacramento CA
    Posts
    17
    Rep Power
    0

    Default

    Actually I solved my problem like this

    bottomContainer.add(hiddenBoxBottomA);
    bottomContainer.add(new JScrollPane(resultTable));
    bottomContainer.add(hiddenBoxBottomB);
    bottomContainer.setPreferredSize(new Dimension(100,200)); //controls the size of bottomContainer
    bottomContainer.revalidate();
    I set the size of the bottomContainer which contains the JScrollPane which contains the JTabel called resultTable

Similar Threads

  1. Setting frame size to the size of an image
    By Yoruichi in forum AWT / Swing
    Replies: 5
    Last Post: 04-22-2009, 04:37 PM
  2. Set the Size of jvm.log file
    By kasidandu in forum New To Java
    Replies: 0
    Last Post: 03-16-2009, 04:08 PM
  3. Replies: 2
    Last Post: 05-15-2008, 10:15 AM
  4. Object size
    By kavithas in forum New To Java
    Replies: 0
    Last Post: 11-30-2007, 12:00 PM
  5. how to set an image size
    By valery in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 08:27 PM

Posting Permissions

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