I will rephrase my question:**
How to prevent Java ScrollBar from being enabled in FlowLayout when there is enough space to show all items by warping them.
**
Here a screenshot of what I am trying to achieve:
Note that scrollbar is disabled when it is not necessary.

And when you resize the window scrollbar should appear if some items are out the viewplane

P.S. I am aware of things called documentation and web.
Your updated screen shots suggest that you may be looking for Wrap Layout, which "extends the
FlowLayout" in a way that "will result in synchronizing the preferred size of the container with the layout of the container." See also Creating a Custom Layout Manager.