Default color of JTable row
Asked Answered
K

1

8

I have written one program where I am highlighting certain rows based on criteria.I posted one question regarding that :- JTable CustomRenderer Issue

Solution given for this problem was that I need to set color in else for rows which do not come under criteria. So I decided that in else I will use default color of JTable. Modified code is

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

So far so good, I am getting required behaviour, but when I am trying to make jar following warning is coming :-

warning: DefaultLookup is internal proprietary API and may be removed in a future release

So can any one suggest me if there is any other way to setting rows to default color in JTable.

Kythera answered 7/12, 2012 at 21:13 Comment(1)
for better help sooner post an SSCCE, demonstrated a.m. issue, short, runnable, compilable, no idea whats wrong from this descriptionAltimeter
W
15

Replacing DefaultLookup.getColor(this, ui, "Table.dropCellForeground") with javax.swing.UIManager.getColor("Table.dropCellForeground") should fix your problem.

Also you can modify (globally) the default values present in your Look & Feel just by using the put(Object key, Object value) method from UIManager

Weighty answered 7/12, 2012 at 22:47 Comment(2)
See this answer for how to get the color keys. #731149Monikamoniker
See this URL for a list of color keys. alvinalexander.com/java/java-uimanager-color-keys-listMonikamoniker

© 2022 - 2024 — McMap. All rights reserved.