I want to create a button class and use a ButtonUI to render it instead of overriding the paint component method. I do not want to use this ButtonUI for ALL JButtons. Is that possible? I’ve only ever seen UIManager.put("ButtonUI","MyCustomButtonUI"), but does this affect ALL JButton rendering? Is it possible to limit the scope of the put operation?
I want to create a button class and use a ButtonUI to render it
Share
JButton.setUI(ButtonUI)sets the UI for just oneJButton. Use that in conjunction with a factory:EDIT: Or, since you say it’s constant for a certain subclass, just call
setUI()from the constructor for that subclass.Another alternative might be to override the method
getUIClassID()in your subclass. This will probably allow you to still use theUIManagerto choose which style to use, but I haven’t tested it.