how to use the layout managers in swing java

后端 未结 3 844
青春惊慌失措
青春惊慌失措 2021-01-14 18:28

I\'m new to layout managers like Flow, borders, ...
I mostly use setBounds() to set the position of my components.

I read

3条回答
  •  鱼传尺愫
    2021-01-14 19:15

    ..which is the best and most used layout (?)

    Nested layouts. Use whatever layout works best for different groups of GUI components, then put them in panels inside other panels (with other layouts). See this Nested Layout Example for a demo. of combining layouts.

    As to which best individual layouts to use, do the tutorial linked by MBFG to get a feel for what each can achieve, their strengths & weaknesses.

    I will commonly use nested combinations of BorderLayout, GridLayout & FlowLayout, with an occasional GridBagLayout.

提交回复
热议问题