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

  • SEARCH
  • Home
  • 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 8467151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:33:37+00:00 2026-06-10T15:33:37+00:00

I make a table with multiline cell, it worked fine, but I want to

  • 0

I make a table with multiline cell, it worked fine, but I want to change the color of a single row after making specific colomns muliline cell, not the color of the whole colomn. How can i do that?

here is an image after making colomn 2 multiline cell, but the whole colomn become white
enter image description here

this is what i did :

jTable1.getColumnModel().getColumn(1).setCellRenderer( new TextAreaRenderer2()); 

String test = "sunday \n monday ";

jTable1.getModel().setValueAt(test, 0, 3);
jTable1.getModel().setValueAt(test, 0, 1);
jTable1.getModel().setValueAt(test, 0, 2);

and this is TextAreaRenderer2 class :

public class TextAreaRenderer2 extends JTextArea
     implements TableCellRenderer {

     public TextAreaRenderer2() {

         Font font = new Font("Aparajita", Font.BOLD + Font.ITALIC, 16);

         setLineWrap(true);
         setWrapStyleWord(true);
         setBackground(Color.yellow);
         setBorder(BorderFactory.createEmptyBorder());
         setFont(font);

     } 

     @Override
     public Component getTableCellRendererComponent(JTable jTable,
          Object obj, boolean isSelected, boolean hasFocus, int row,
          int column) {

         setText((String)obj);
         setBackground(Color.WHITE);


         return this;
     }
 }
  • 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-06-10T15:33:39+00:00Added an answer on June 10, 2026 at 3:33 pm

    In your TableAreaRenderer2 class, in the getTableCellRendererComponent method you should set the background color based on the row. Something like this:

    if (row % 6 < 3) {
      setBackground(Color.LIGHT_GRAY);
    } else {
      setBackground(Color.WHITE);
    }
    

    The above code will make 3 rows light gray the next 3 white and repeat the same pattern.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a table where the entries expire 24 hours after they
I want to make my table to be at least 50px but still enlarge
I want to make a table view in my iPhone Application.. In that table
I am trying to make a table cell that when tapped calls a phone
hai.all..can you tell me how to make table in jquery? i want using this
I want to implement delete column in Android's SQLite. I want to make table
How can I make table column width change dynamically according to the data inside
I want to make a table that simply has two integer columns to serve
I'm trying to make a table that has one webform per table row. The
I want to make a table in SqlServer that will add, on insert, a

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.