Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to load custom UI using L&F?

 
Rich Smyth
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a class that extends WindowsComboBoxUI. I want to set up my L&F (an extension of the Windows L&F) to use this UI.

I've set the UIManager defaults so that "ComboBoxUI" maps to "myProject.myComboBoxUI" and "myProject.myComboBoxUI" maps to Class.forName("myProject.myComboBoxUI").

After calling UIManger.setLookAndFeel("myProject.MyLookAndFeel") my
custom class is not being used to paint my comboboxes: myComboBox.getUI()
returns an instance of WindowsComboBoxUI.

Any ideas what I'm doing wrong?

thanks
Rich
 
Brian Cole
Author
Ranch Hand
Posts: 906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rich Smyth:
I've set the UIManager defaults so that "ComboBoxUI" maps to "myProject.myComboBoxUI"


How did you set the ui default?

Did you override initClassDefaults()? If not, then
initClassDefaults() may be clobbering your setting.
If so, then I dunno, you didn't give much information
for me to work with.
 
Rich Smyth
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you set the ui default?




I was under the impression that the code above is all that's required to force my custom class to be used by my L&F. Since it does not work I've
obviously missed something.
 
Brian Cole
Author
Ranch Hand
Posts: 906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know, you only need to set the "ComboBoxUI" -> "myPackage.MyComboBoxUI" mapping, though the other one shouldn't harm anything.

Instead of using an Object[] array you could just do table.put("ComboBoxUI", "myPackage.MyComboBoxUI") after the call to super.initClassDefaults() but, again, I don't see how this would change anything.

Are you instantiating the JComboBox after calling UIManager.setLookAndFeel()?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic