how to use the layout managers in swing java

后端 未结 3 845
青春惊慌失措
青春惊慌失措 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:08

    Besides "standard" Swing layouts (part of the JDK), there are many third-party (mostly open source) LayoutManagers that often are much better than Swing ones.

    For a comparison of many LayoutManagers on a real example (with code), check out this link, although a bit old, it still shows the various features and ease of use of predominant LayoutManagers nowadays.

    In general, I would advise DesignGridLayout which, although quite powerful, is very easy to use (you don't need a GUI designer to use and it's easy to maintain layout code of existing panels); it just takes one hour to understand it.

    Also, MigLayout is viewed as the most flexible one (might be useful if you need very complex layouts), but it takes more time to get used to it, and sometimes you have to use "tricks"to make it work as you want.

提交回复
热议问题