Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fill up the empty space of a FlowLayout

I have a flowlayout panel which has a textfield inside. Although the textfield is not that wide but I want to place components on the next line. How do I fill the remaining space with an empty box?

like image 895
Soler Mani Avatar asked Oct 23 '25 01:10

Soler Mani


1 Answers

If you need more deterministic control over the way your components are laid out, you should consider using a different layout manager such as BoxLayout, GridLayout, or GridBagLayout. You may be able to trick FlowLayout into doing what you want, but what happens if the user resizes the window? Or changes their font DPI at the OS level? Instead of having your components be on different lines as a side effect of putting dummy components into a FlowLayout, consider expressing the above/below relationship more explicitly with a layout manager that has those concepts built in (e.g. GridBagConstraints.gridy).

like image 177
Mike Clark Avatar answered Oct 25 '25 14:10

Mike Clark



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!