GUI layout suggestions?

So, I want to create a new JList and a new JPanel at the bottom, but I'm not too familiar with BoxLayout , FlowLayout , etc. What do you suggest, so I can make my GUI turn into something like this:

I drew this on Paint, excuse my drawing.

Sorry my drawing and thanks to everyone who can help! :)

Edit: what does it do? JPanel.setLayout (new BoxLayout (JPanel, BoxLayout.PAGE_AXIS));

+4
source share
2 answers

Use MigLayout . It is very easy to use and has only a very small learning curve. It can easily handle the layout you intend to use. In particular, start with the Quick Start Guide and then Whitepaper for the rest of the API)

The specific parts that you need to see using MigLayout are the docking elements (on the right and bottom, it looks like) and fill , since it looks like you want things to take up all the space.

Other than that, you probably won't need much more to indicate the layout.

As an example, using MigLayout and SwingBuilder in Griffon , here is how I could lay out what you have:

 migLayout(layoutConstraints: 'fill, wrap 2', columnConstraints: '[grow|]', rowConstraints: '[grow|]') panel (constraints: 'spany 2, grow') { // Main content with the picture go in here } list(constraints: 'grow') { // Top list } list(constraints: 'grow') { // Bottom list } panel(constraints: 'grow') { // Bottom panel } panel() { // Button panel } 

There are probably many ways to do this, and I did not build the link and run it myself, so I am not 100% sure that it works, but it should serve as a good starting point.

+3
source

DEither use GridBadLayout or use nested panels with BorderLayout. You need to have several levels of JPanel containers that define the layout, and then add functional components to them.

In your example, I would start with a panel in the Center (panel A) and a panel on the eastern border (panel B). then use BoxLayout for panel B and add JList, JButton, JLabel and Jlists, as well as tag removal buttons.

For panel A, add another container panel on the southern border (panel C), another in the center (panel D) and another on the eastern border (panel E). Add two new lists in panel E using boxlayout and fig. In panel C.

Hope this helps

-1
source

Source: https://habr.com/ru/post/1383924/


All Articles