java which layout manager suitable for this task?

后端 未结 4 1044
星月不相逢
星月不相逢 2021-01-13 17:51

I have a JPanel parent with 3 JPanel children inside. They all currently make use of GridLayout and together represent a UML class. Problem is that when I add a new attribu

4条回答
  •  无人共我
    2021-01-13 18:19

    Unfortunately I am not 100% sure I understood your layout. It will be better if you can attach picture.

    But if Grid Layout grows not as you want you can either use GridBagLayout that can do almost everything but a little bit complicated or use a combination of Border and other layouts.

    Probably several border layout can help you. In this layout center is growing fast while north, south, west and east are growing slower. Try to use them.

    Check BoxLayout too.

    If you are going to create a lot of complicated dialog boxes check out MigLayout. Although some learning curve exists this layout can really help you to save hours and days.

    Since you updated your question now I can definitely say that you can define BorderLayout, with North, South and Center.

    Center will contain Grid layout with 2 rows. Each row will contain Border layeout again. The upper border layout will contain other pannel in the south. The lower border layout willcontaint border layout in the North.

    Each one of that layouts will contain yet another border layouy with label in the west and text field in the center.

提交回复
热议问题