Difficulties in understanding GroupLayout

enter image description here

I wanted to do something similar to the one with the frame in BLUE (right side), so I started with a simple one that has 3 panels (top left)

I could not figure out how to use GroupLayout , and for me this is my code. It turns out that it is located on the bottom left. Can anyone tell me where is wrong with my understanding on GroupLayout ? Thanks.

 layout.setHorizontalGroup(layout.createSequentialGroup() .addComponent(yellow) .addComponent(green) .addGroup(layout.createParallelGroup()) .addComponent(pink) ); layout.setVerticalGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup()) .addComponent(yellow) .addComponent(green) .addComponent(pink) ); 
+4
source share
1 answer

When looking at the horizontal layout, you have the upper part (yellow / green) and the lower part (pink) in parallel . The upper part displays the sequence of yellow and green:

 layout.setHorizontalGroup( layout.createParallelGroup() // upper and lower part show parallel layout .addGroup(layout.createSequentialGroup() // <- upper part .addComponent(yellow) .addComponent(green) ).addComponent(pink) // <- lower part ); 

On the other hand, the vertical layout is a sequence of the upper part (yellow and green in parallel , that is, side by side) and the lower part (pink).

 layout.setVerticalGroup( layout.createSequentialGroup() // upper and lower part sequentially .addGroup(layout.createParallelGroup() // <- upper part .addComponent(yellow) .addComponent(green) ).addComponent(pink) // <- lower part ); 
+1
source

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


All Articles