java - LookAndFeel-independent reference of color keys -


i working on set of custom controls product of company i'm working in. this, extending lot of swing controls , overriding lot of paint methods.

in order maintain consistent color scheme, receive colors paint, setbackground etc. methods using uimanager.getcolor.

this fine until noticed nimbus lookandfeel, shipped current jre versions, uses totally different color keys, many things looks totally out of place.

for instance, while other stock lookandfeels (metal, windows classic, windows, cde/motif, gtk) have defined key "text" bright background texts , "texttext" corresponding foreground color, "text" in nimbus black foreground color, , standard text background color not seem exist.

"textfield.background" work, that, instance, doesn't exist windows lookandfeels.

i suppose problem now. don't want have maintain set of color keys each laf, knows lafs added in future , company may decide use.

a simple solution getting rid of nimbus, of course, understandably boss doesn't idea @ all, besides nimbus part of jre these days , should supported.

so wonder whether there any standardized way laf-dependent colors like, say, "text background / foreground", "selected text bg/ fg", etc.?

there no way around - have create own abstraction layer color names (and possibly other property names).

basically have stock lookandfeels (metal, windows classic, windows, cde/motif, gtk) use own color names , nimbus uses different names.

create class e.g. lafproperties each property/color have method (e.g. "gettextcolor"). class returns properties classic laf styles. extend class nimbus, , change methods differ in nimbus.

if stock lafs , nimbus have of properties differently named, use might use interface , 2 implementing classes.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -