The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

BorderLayout makes everything disappear

Hey, so when i attempt to use the BorderLayout, then run the program nothing is shown in the window, my slider/textboxes and labels are gone. Then when i revert back to using a FlowLayout, they come back.

Re: BorderLayout makes everything disappear

Originally Posted by jason3460

can someone tell me how i would implement the BorderLayout correctly

You should take some time to learn, at least, the most basic layout managers like BorderLayout, FlowLayout, GridLayout (and put also GridBagLayout). Each of these has its specific features, restrictions and so on.
Without a good background on these concepts you will always have doubts and you won't understand "why" things happen in that way.

FlowLayout is very simple, it can manage any number of components. As the name "Flow" implies, FlowLayout arranges components in one row and if it's not sufficient, components can "flow" on the next row. Exactly like words flow in a word processor or a web page.

BorderLayout can manage only 5 components. They are arranged in 5 areas whose names are conceptually: "north", "south", "east", "west", "center". Only 1 component can appear in one area.
When you want to add a component in a BorderLayout you should write code like this (container is the container with the BorderLayout, can be implicitly the this if you are extending eg. JPanel):

NORTH, CENTER, EAST, etc... are constants in BorderLayout for "absolute" positioning (the east is always .... at east). There are other constants for "relative" positioning. But I don't want to go further. You need a background on these things, so please read: