[ADDED] setMaximumHeight for WebPanel

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

[ADDED] setMaximumHeight for WebPanel

Postby Endogen » Thu Jan 30, 2014 11:40 pm

There is a setMinimumHeight() method for a WebPanel but there is no setMaximumHeight() - why? I would need it right now :) There of course is the method setMaximumSize() but i don't want to set the width.

Thanks,
Endo
Endogen
 
Posts: 14
Joined: Tue Jan 22, 2013 12:48 pm

Re: setMaximumHeight for WebPanel

Postby mgarin » Thu Feb 27, 2014 6:57 pm

I didn't plan to add setMaximumWidth/Height methods for two reasons:
1. They are rarely used (what is your case by the way? i bet there is a better solution)
2. There are some serious issues those methods might cause in some complex cases
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: setMaximumHeight for WebPanel

Postby Endogen » Sat Mar 01, 2014 12:51 am

I wanted to have a WebList with panels. So i created my own class that extends WebPanel and set that as the CellRenderer for the WebList. Now i wanted to have this behavior: When i resize the list, the panels should be horizontally also resized but vertically they should grow only according to the length of the text inside but not bigger then setMaximumHeight. That was what i wanted to do.

Right now, i achieve all of that with
Code: Select all
contentPanel.setLayout(new JideBoxLayout(contentPanel, JideBoxLayout.Y_AXIS));

... except of the maximal height functionality, that doesnt work. The panels always grow with the text inside and do not have a maximal height.

I guess i could also achieve this by using MigLayout but i can't figure out how.
Endogen
 
Posts: 14
Joined: Tue Jan 22, 2013 12:48 pm

Re: setMaximumHeight for WebPanel

Postby mgarin » Tue Mar 04, 2014 2:35 pm

There is a simple way to achieve that - just override the "getPreferredSize" method in your custom panel.
Something like this should be enough:
Code: Select all
final WebPanel panel = new WebPanel ()
{
    @Override
    public Dimension getPreferredSize ()
    {
        final Dimension ps = super.getPreferredSize ();
        ps.height = Math.min ( ps.height, 100 );
        return ps;
    }
};


Anyway, i will consider adding the "setMaximumWidth/Height" methods.
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: setMaximumHeight for WebPanel

Postby Endogen » Tue Mar 04, 2014 10:04 pm

That's a good solution, thanks for that! :)
Endogen
 
Posts: 14
Joined: Tue Jan 22, 2013 12:48 pm

Re: setMaximumHeight for WebPanel

Postby mgarin » Wed Mar 05, 2014 11:54 am

That is basically the same way my additional methods do the trick :)
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg

Re: setMaximumHeight for WebPanel

Postby mgarin » Tue Sep 30, 2014 12:11 pm

Starting with v1.29 update there will be setMaximumWidth and setMaximumHeight methods available for Web-components which will limit component's preferred size with specified values.

Note that those values are totally different from values provided into Swing setMaximumSize method which is not used by some layout managers and might not affect anything.
User avatar
mgarin
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 1 guest

cron