JTable行的默认颜色

Add*_*ict 4 java swing background jtable tablecellrenderer

我写了一个程序,我根据标准突出显示某些行.我发布了一个问题: - JTable CustomRenderer Issue

给出这个问题的解决方案是我需要为不符合条件的行设置其他颜色.所以我决定在其他地方我会使用默认颜色JTable.修改后的代码是

else{
           c.setForeground(DefaultLookup.getColor(this, ui, "Table.dropCellForeground")); 
           c.setBackground(DefaultLookup.getColor(this, ui, "Table.dropCellBackground"));
        } 
Run Code Online (Sandbox Code Playgroud)

到目前为止这么好,我得到了必要的行为,但是当我试图让jar跟随警告时: -

警告:DefaultLookup是内部专有API,可能会在将来的版本中删除

所以任何人都可以建议我是否有任何其他方法将行设置为默认颜色JTable.

小智 10

更换DefaultLookup.getColor(this, ui, "Table.dropCellForeground")javax.swing.UIManager.getColor("Table.dropCellForeground")应解决您的问题.

您还可以使用UIManager中put(Object key, Object value)方法修改(全局)Look&Feel中存在的默认值