Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resize component on JToolbar

I'm writing a program with a toolbar in the head. The only problem is that I can't set the correct size on the component in my toolbar, namely a datepicker.

screenshot

So I want to resize the datepicker in the toolbar. How can I fix this?

The most beautiful option would be to resize it that the textfield would just be big enough to display the date.

like image 658
Joël Craenhals Avatar asked Dec 31 '25 19:12

Joël Craenhals


1 Answers

For the toolbar to pickup component size properly you have to set its preferred, maximum and minimum size. Here is what works for me:

Dimension d = cmpt.getPreferredSize();
d.width = YOUR_NEW_WIDTH;
cmpt.setMinimumSize(d);
cmpt.setMaximumSize(d);
toolbar.add(cmpt);
like image 145
Eugene Ryzhikov Avatar answered Jan 03 '26 09:01

Eugene Ryzhikov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!