Re: UIDefaults key?
On 8/6/2014 12:25 PM, Knute Johnson wrote:
JComponent has a method, getUIClassID(), to return the UIDefaults key
for the ComponentUI subclass. A JTextField returns a key of
TextFieldUI. A typical subclass is
javax.swing.plaf.metal.MetalTextFieldUI.
All the interesting details in the UIDefaults however use keys such as
TextField.foreground, TextField.border, TextField.margin etc. Is there
any way to get the prefix, TextField, from the component other than
stripping the UI off the end of the UIClassID?
Climbing the class hierarchy from MetalTextFieldUI up to
BasicTextFieldUI, I find the method
/**
* Fetches the name used as a key to lookup properties through the
* UIManager. This is used as a prefix to all the standard
* text properties.
*
* @return the name ("TextField")
*/
protected String getPropertyPrefix() {
return "TextField";
}
.... which sort of looks like what you're after. (But I haven't
researched any other delegate classes, so it's possible they're
different.)
--
esosman@comcast-dot-net.invalid