简体   繁体   English

使用Java PaginationUI swing根据列值更改行颜色

[英]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. 我需要检查“数据” Arraylist的最后一个值。 Depending on that if value is "abc" ,need to change the value of that row. 根据该值是否为“ abc”,需要更改该行的值。

I went through Change the background color of a row in a JTable 我经历了更改JTable中一行的背景颜色

and did most of the things suggested therein, except the MyTableCellRenderer, which I did not understand where that is implemented. 并完成了其中建议的大多数事情,除了MyTableCellRenderer,我不知道在哪里实现。

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. 请参阅表行渲染以获取一种解决方案,该解决方案可以通过重写JTableprepareRenderer(...)方法来工作,因此您无需为表中的每种数据类型提供自定义渲染器。

I need to check the last value of the "data" Arraylist 我需要检查“数据” Arraylist的最后一个值

No, you should NOT be referencing the ArrayList. 不,您不应该引用ArrayList。 You should only ever reference the data in the TableModel . 您应该只引用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. 如果上述解决方案SSCCE ,请发布您的SSCCE来演示您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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