Alternative to absolute layout?

前端 未结 3 751
礼貌的吻别
礼貌的吻别 2021-01-15 14:15

Is there a layout manager that gives the same degree of control as Absolute Positioning? But also makes auto resizing possible? Something where you could place elements usi

3条回答
  •  臣服心动
    2021-01-15 14:37

    GridBagLayout is the most flexible standard layout manager in Swing and it can achieve practically anything you need, although nowhere near as simply as how you imagine by just using relative coordinates (what you mean, I guess, is 0-100% relative to the frame size).

    You may find the official documentation for GridBagLayout here, which also has some figures and examples.

    You can also check out the open-source MiG Layout, which is much more convenient that GridBagLayout and also a bit more powerful. It is the mother of all layout managers.

提交回复
热议问题