Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7601953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:17:23+00:00 2026-05-30T23:17:23+00:00

I cant find the answer to this anywhere – i am sure it is

  • 0

I cant find the answer to this anywhere – i am sure it is really simple but im quite confused!

i want to change the colour of the cell background when the value changes.
I have written a cell renderer below:

public class CyanTableCellRenderer extends DefaultTableCellRenderer {

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

    cell.setBackground( Color.CYAN );
    return cell;
}
}

I want to pass the value of the cell from the event in the listener – to highlight the cell.

Can anyone help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:17:25+00:00Added an answer on May 30, 2026 at 11:17 pm

    As suggested by @mKorbel, prepareRenderer() can apply changes to any selected renderer. Alternatively, you can condition the color based on the isSelected parameter of your renderer.

    if (isSelect) {
        this.setBackground(Color.cyan);
    }
    

    If you just want to change the default background color for selected cells, alter the UIManager property Table.selectionBackground early in your program. This will affect all tables during execution.

    UIManager.put("Table.selectionBackground", Color.cyan);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like a really simple question, but I can't find the answer anywhere.
This is such a simple problem, but I can't find an answer anywhere... I
This may seem like a simple question, but I can't find the answer anywhere
This is really only a short question, but I can't find the answer anywhere.
I'm sure this is simple with .parent() or such but can't find an answer
i havent been able to find the answer for this anywhere but i cant
This seems like a simple question but I can't find the answer anywhere. I've
Sorry if this question is very easy, but I can't find the answer anywhere.
I know this is somewhat subjective, but I can't find an honest answer anywhere.
Been searching all over for this but cant find an answer so thought I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.