Re: [問題] 如何改變JTable的Row Color?

看板java作者 (青菜蘿卜)時間18年前 (2007/05/11 16:41), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
感謝您的回答。 想法有點不太一樣,前輩的做法是update符合的cell而已。 而我想要的是整個row的顏色。 不過,我已經試出方法了。 就是 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); int VALIDATION_COL = 4; boolean isEnabled = Boolean.parseBoolean( table.getModel().getValueAt(row, VALIDATION_COL).toString()); if(isEnabled) { cell.setBackground(Color.BLUE); } else { cell.setBackground(Color.RED); } return cell; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.95.190.120
文章代碼(AID): #16H2maAi (java)
文章代碼(AID): #16H2maAi (java)