Use EmptyBorderUIResource instead of EmptyBorder

Request new features and improvements you want to see in WebLaF.
I will answer any request so don't hesitate and post it!

Use EmptyBorderUIResource instead of EmptyBorder

Postby robert » Sun Mar 31, 2013 9:00 am

WebLaF installs lots and lots of EmptyBorders since it has its own mechanism for rendering component borders. It should instead be installing instances of EmptyBorderUIResource; this would facilitate runtime LaF switching. The BasicLookAndFeel base class already handles uninstalling UIResource properties such as borders when switching to a new LaF, so you'd only have to switch the border instantiation calls.
Posts: 4
Joined: Fri Mar 15, 2013 3:07 am

Re: Use EmptyBorderUIResource instead of EmptyBorder

Postby mgarin » Mon Apr 01, 2013 5:54 pm

I know that Swing has its own mechanism for borders lazy initialization. It works well when you know what border goes where from the beginning. For example if you know that all of your buttons have a gray line border with 1px width by default - you can set its settings just once using BorderUIResource.LineBorderUIResource. It will be then used in each button UI instance as a border source.

The problem here is that almost all of borders used in WebLaF are calculated in runtime when the UI is installed or updated. Update might happen at any time - for example when some of UI settings are modified, or default style has changed (styles manager coming a bit later, just telling about it ahead). In this situation updating a border created from a lazy value will be a real pain and also makes that lazy initialization useless.

Also soon enough it will be possible to set your own border that will not be replaced by WebLaF border. From the inside - component UI will create an additional border that will combine L&F empty border (that is used for proper margins) and your custom border and will simply keep WebLaF border updated.

These are the reasons why i am not using default Swing borders lazy initialization mechanism.


I guess your suggestion was about the problem that WebLaF doesn't clean up some of component settings it modifies (including borders)?

If so - i am still working on that problem and will be adding fixes for various UIs so that WebLaF won't leave any traces after uninstallation.
User avatar
Site Admin
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Return to Suggestions

Who is online

Users browsing this forum: No registered users and 2 guests