繁体   English   中英

JTable行的默认颜色

[英]Default color of JTable row

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

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

else{
           c.setForeground(DefaultLookup.getColor(this, ui, "Table.dropCellForeground")); 
           c.setBackground(DefaultLookup.getColor(this, ui, "Table.dropCellBackground"));
        } 

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

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

因此,任何人都可以建议我是否有任何其他方法可以在JTable中将行设置为默认颜色。

javax.swing.UIManager.getColor("Table.dropCellForeground")替换DefaultLookup.getColor(this, ui, "Table.dropCellForeground") javax.swing.UIManager.getColor("Table.dropCellForeground")可以解决您的问题。

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

暂无
暂无

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

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