Search code examples
javaswinguser-interfaceborder-layout

Border Layout Positioning on bottom right (but not top) corner


So i have been doing gui for my program. But there is problem with positioning things on borderlayout.

enter image description here

There is positioning that i want them to be. Using BorderLayout. But this is where they currently are

enter image description here

So i want spinner between right and left combobox, but under textarea and button. Like on picture i mentioned before. I have no idea what to do.


Solution

  • Just use a combination of layout managers in a tree-like manner, i.e., container with a specific layout inside other containers with (possible) other layouts. For example, this might be a snippet for your app:

    JPanel innerPanel = new JPanel( new BorderLayout() );
    innerPanel.add( textArea, BorderLayout.CENTER );
    innerPanel.add( spinner, BorderLayout.SOUTH );
    
    JPanel outerPanel = new JPanel( new BorderLayout() );
    outerPanel.add( calcButton, BorderLayout.NORTH );
    outerPanel.add( panzerCombo, BorderLayout.WEST );
    outerPanel.add( widthCombo, BorderLayout.EAST );
    outerPanel.add( innerPanel , BorderLayout.CENTER );