Search code examples
javaswinglayout-managerflowlayout

FlowLayout in conjection with setBounds()


I have a JFrame. I use setBounds() for determine position and size, but when I use frame.setLayout( new FlowLayout() ) all components are cluttered.

What is the solution?


Solution

  • 1) setBounds() is bad practice with null LayoutManager(setLayout(null)).

    2) When you use FlowLayout, it calculates positions and sizes of components.

    So, you can't mixing 2 approaches. Examine how to use LayoutManager.