File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes How to load custom UI  using L&F? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to load custom UI  using L&F?" Watch "How to load custom UI  using L&F?" New topic
Author

How to load custom UI using L&F?

Rich Smyth
Ranch Hand

Joined: May 30, 2002
Posts: 87
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

Joined: Sep 20, 2005
Posts: 862
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.


bitguru blog
Rich Smyth
Ranch Hand

Joined: May 30, 2002
Posts: 87
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

Joined: Sep 20, 2005
Posts: 862
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()?
 
Consider Paul's rocket mass heater.
 
subject: How to load custom UI using L&F?
 
Similar Threads
change the JInternalFrame.focus colour to another colour
disable selection on double click in textpane
JScrollBar problem!!!
UI's and Look-And-Feels
Problem with updating look and feel colors of swing components dynamically