[SOLVED] Override checkbox icon

Discuss here any questions about the WebLaF library.
Bugs can be posted directly to GitHub issues tracker.

[SOLVED] Override checkbox icon

Postby joelSurfer2003 » Wed Sep 02, 2015 6:54 pm

I was wondering what the best way is to override the checkbox icon globally for my application... I am having to add support for high DPI monitors, and the checkbox and radiobuttons do not scale... I know I can change the icons for each instance, but I was hoping for an easier way that would just work for all JCheckBox instances... I am thinking about extending WebCheckBoxUI and overriding createCheckStateIcon() where that method would return a custom CheckIcon object... Would that work, or is there a better way?
joelSurfer2003
 
Posts: 3
Joined: Wed Sep 02, 2015 6:47 pm

Re: Override checkbox icon

Postby mgarin » Wed Sep 02, 2015 7:21 pm

Right now that should be the best way to do it.

With the next update it would be possible to place a custom painter for all checkboxes without modifying the UI through the custom styling system. I will be describing how such things can be done later on GitHub wiki.
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: Override checkbox icon

Postby joelSurfer2003 » Wed Sep 02, 2015 9:53 pm

Thanks for the quick response!

One more question... I am setting the L&F by using "WebLookAndFeel.install()" ... How do I get my extended WebCheckBoxUI to used by JCheckBox instances... I tried "new MyWebCheckBoxUI().installUI(new JCheckBox());" but that does not work...

Thanks!
joelSurfer2003
 
Posts: 3
Joined: Wed Sep 02, 2015 6:47 pm

Re: Override checkbox icon

Postby joelSurfer2003 » Wed Sep 02, 2015 10:07 pm

sorry, "UIManager.getDefaults().put("CheckBoxUI", MyWebCheckBoxUI.class.getCanonicalName());" worked...

Thanks again!
joelSurfer2003
 
Posts: 3
Joined: Wed Sep 02, 2015 6:47 pm

Re: Override checkbox icon

Postby mgarin » Fri Sep 04, 2015 12:05 pm

You are welcome :)
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg


Return to Questions

Who is online

Users browsing this forum: No registered users and 1 guest

cron