Results 1 to 4 of 4
  1. #1
    doru.chiulan is offline Member
    Join Date
    Jul 2012
    Posts
    9
    Rep Power
    0

    Default Empty JTable issue(blank rows)

    Hy guys!

    I have a problem, i want to create a empty table in a scrollable pane that has fixed width, and a minimum height of 200. When i say "empty" i mean it must have as many empty rows as it needs so it can fill scrollable pane's height.

    Something like this (the one in the left bottom part of the picture):

    The problem is...i can use a solution but is not really what i need. I added many empty rows so i am assured that the table fills also the minimum height of the scrollable pane, and also the maximum height. BUT, this adds a vertical scrollbar , and i don't want this only if i have records in the "non visible" area. I want scrollbar to ignore the empty rows. In the picture there is no scrollbar.

    Or if you have a better solution without this ugly idea of adding blank rows, I would be grateful.

    Thank you
    Last edited by DarrylBurke; 08-10-2012 at 10:04 AM.

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: Empty JTable issue(blank rows)

    If I understand, you just want to paint every other row - whether or not there are contents in said row. You can extend JTable and do the painting of empty rows manually. There are a couple of example for how to do this online - requires you to extend JTable and override its default painting behavior. Here's one from a quick google search: elliotth's blog: Alternating row colors in JTable

  3. #3
    doru.chiulan is offline Member
    Join Date
    Jul 2012
    Posts
    9
    Rep Power
    0

    Default Re: Empty JTable issue(blank rows)

    thank you, good article. I'll give it a go to see the miracle happening :))

  4. #4
    doru.chiulan is offline Member
    Join Date
    Jul 2012
    Posts
    9
    Rep Power
    0

    Default Re: Empty JTable issue(blank rows)

    Solved, works like a charm, you can close this thread :D

Similar Threads

  1. Jtable rows
    By riddhishah28 in forum AWT / Swing
    Replies: 3
    Last Post: 02-18-2011, 06:24 AM
  2. Listening rows in JTable ??
    By Stephen Douglas in forum New To Java
    Replies: 2
    Last Post: 04-10-2010, 04:45 PM
  3. Replies: 2
    Last Post: 12-10-2009, 12:06 PM
  4. JTable insertRows() just adding blank rows
    By Jacob_ in forum AWT / Swing
    Replies: 4
    Last Post: 10-10-2009, 03:56 AM
  5. Highlight rows of a jtable
    By simmi in forum AWT / Swing
    Replies: 5
    Last Post: 08-20-2009, 01:13 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
  •