简体   繁体   中英

Change row color based on column value using Java PaginationUI swing

I am trying to change the row color based on the last column's value

Following is the code used:

PaginationUI pageUI =new PaginationUI();
        this.dialog = new JDialog(jFrame, csvName, true);
 pageUI.setCurrentPageIndex(1);
        pageUI.setItemsPerPage(itemsPerPage);
        pageUI.setHeader(header);
        pageUI.setData(data);   

        pageUI.paintPaginatedData();  

Plz help. I need to check the last value of the "data" Arraylist. Depending on that if value is "abc" ,need to change the value of that row.

I went through Change the background color of a row in a JTable

and did most of the things suggested therein, except the MyTableCellRenderer, which I did not understand where that is implemented.

i am trying to change the row color based on the last column's value

See Table Row Rendering for one solution that works by overriding the prepareRenderer(...) method of the JTable , so you don't need to provide a custom renderer for each data type in the table.

I need to check the last value of the "data" Arraylist

No, you should NOT be referencing the ArrayList. You should only ever reference the data in the TableModel .

and did most of the things suggested therein

Then it should work. The problem is with your code. Post your SSCCE that demonstrates your problem if the above solution doesn't help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM