1
votes

I am trying to organize my over all program to have a BorderLayout(NORTH EAST SOUTH WEST CENTER), mainly just to utilize the north center and south aspects. I am in the process of creating flow panels to go into each part of the layout, but they are not stacking correctly, instead they are just lining up from left to right. My code is as follows.

JPanel SortingSouth = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));
    SortingSouth.add(DocumentLabel);
    SortingSouth.add(Document);

    Sorting.add(SortingNorth, BorderLayout.NORTH);
    Sorting.add(SortingSouth, BorderLayout.SOUTH);

Sorting is my overall Panel to contain the other 3 panels I intend to create, and is set up with a border layout. I guess my question is why is my border layout not working when I give it a flow layout to one of its containers? (I know this is just a short snippet of my code, but the rest is just declaring what the labels are, etc, my SortingNorth is structured the same)

1
Have a look at Rob's WrapLayout which has a good explanation of what the underlying problem is and how it can be fixed. You might also consider using a GridBagLayout instead of FlowLayout - MadProgrammer
Thanks. I will take a look at this. - whiskey golf
Variable names should not start with an upper case character. - camickr

1 Answers

1
votes

Have you tried this?

JPanel sorting = new JPanel(new BorderLayout());

(Also, try not to write you variables with the first letter in uppercase)