0

我希望能够做两件事:

  1. 根据索引设置行的颜色,所以第一行是红色,第二行是蓝色,第三行是绿色
  2. 能够基于某些东西设置列的颜色,无论是索引还是它们的名称等,只要有可能。

我不需要检测选择更改或任何东西。有人可以告诉我该怎么做吗?什么方法会有所帮助等?如果没有阅读标题,这是关于DefaultTableModel.JTables

4

1 回答 1

1

set colors of rows based on index,

Table Row Rendering might give you some ideas.

be able to set color of columns also based on something

You can provide a custom render for any column. Then you can add you logic to color the column based on something. Read the JTable API and follow the link to the Swing tutorial on How to Use Table and you will find a section on creating a custom renderer.

于 2013-04-25T15:48:21.523 回答