Choosing the layout managers and number of panels for Java GUI

前端 未结 1 1783
我寻月下人不归
我寻月下人不归 2020-12-18 09:31

I would appreciate, If anyone here is kind enough to recommend me what are the layout managers to choose and how to separate the attached GUI into Jpanels.

相关标签:
1条回答
  • 2020-12-18 09:52

    When trying to determine what layout(s) you should use, you should start by trying to determine areas of responsibility...

    For example...

    enter image description here

    Based on your needs, I might start with a GridBagLayout. This might seem complex, but if you break the UI down into seperate components, focusing on their individual needs, it should become simpler...

    For the panel on the left...

    enter image description here

    I would be temptered to use a GridBagLayout, simply because it allows the components to use there preferred sizes, but still allows you to set up a grid like pattern...

    For the arrow buttons...

    enter image description here

    This becomes a little more complicated, but I would use a GridLayout(2, 3) (2 rows, 3 columns). This will require to add a filler panel at the first and third position along the top row, but still maintain the buttons at a equal size...

    For this panel...

    enter image description here

    I would be tempted to either use a GridBagLayout, because it will allow you to span the rows or even split it again into two separate panels, with the controls on the left in a GridLayout(2, 1) and the control on the right in something like a BorderLayout as required...

    For "progress" panel...

    enter image description here

    I would be tempted to use...GridBagLayout. Mostly because it would allow you to provide more weight to the progress bars then the labels.

    For the main panel...

    enter image description here

    I would probably be tempted to either use a BorderLayout, with the Clear Map on another panel of it's own, allowing it maintain it's preferred size, in the NORTH position and the map panel in the CENTER or even a GridBagLayout depending on what the invidual components are...

    0 讨论(0)
提交回复
热议问题