Designing simple cell renderer for Nimbus look and feel

匆匆过客 提交于 2019-12-04 09:06:58

Your first piece of code if fine.I think you have to use UIManager.getColor("Table.alternateRowColor") for alternate rows and table.getBackground() otherwise. For selected row use table.getSelectionBackground(). So your code might look like

if (isSelected) {
    setBackground(table.getSelectionBackground());
}
else {
    if ( row % 2 == 0 ) {
       setBackground(UIManager.getColor("Table.alternateRowColor"));
    } else { 
       setBackground(table.getBackground());
    }
}

Don't forget to make sure that your panel is opaque and the labels are transparent.

Here is a good link to Nimbus UI defaults: http://www.duncanjauncey.com/java/ui/uimanager/UIDefaults_Java1.6.0_11_Windows_2000_5.0_Nimbus.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!