Results 1 to 4 of 4
  1. #1
    leekaiwei is offline Member
    Join Date
    Aug 2012
    Posts
    2
    Rep Power
    0

    Default How to change row colour of JTable?

    What I have is a JTable of paths of files. If such a file doesn't exist then that row needs to be highlighted. I've searched around for an hour or so and get the general idea that I need to create my own custom TableCellRenderer. I know that it takes 'rows' and 'columns' as parameters but I don't know how to make use of them to access individual rows and change their colours.

    Thanks.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default Re: How to change row colour of JTable?

    Quote Originally Posted by leekaiwei View Post
    I need to create my own custom TableCellRenderer. I know that it takes 'rows' and 'columns' as parameters but I don't know how to make use of them to access individual rows and change their colours.
    There aren't only two parameters. What are the others? Which of those can be used to determine whether you need to highlight the row or not?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default Re: How to change row colour of JTable?

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    leekaiwei is offline Member
    Join Date
    Aug 2012
    Posts
    2
    Rep Power
    0

    Default Re: How to change row colour of JTable?

    Quote Originally Posted by DarrylBurke View Post
    There aren't only two parameters. What are the others? Which of those can be used to determine whether you need to highlight the row or not?

    db
    Actually, I would only be using the row variable. I don't see how the other variables would be able to determine whether it needs to be highlighted in my case...maybe the value variable?

    Is this not allowed?

Similar Threads

  1. Replies: 4
    Last Post: 04-02-2012, 07:57 PM
  2. Replies: 8
    Last Post: 02-17-2012, 05:42 AM
  3. Replies: 4
    Last Post: 05-30-2011, 02:53 AM
  4. Change colour of JOptionPane
    By chirag123 in forum AWT / Swing
    Replies: 1
    Last Post: 05-03-2011, 02:48 AM
  5. Replies: 0
    Last Post: 03-26-2009, 01:23 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
  •