JButton expanding to take up entire frame/container


Hey everyone. I'm trying to make a swing GUI with a button and a label on it. im using a border layout and the label ( in the north field ) shows up fine, but the button takes up the rest of the frame (it's in the center field). any idea how to fix this?


Or just use Absolute layout. It's on the Layouts Pallet.

Or enable it with :

frame = new JFrame();
... //your code here

// to set absolute layout.

This way, you can freely place the control anywhere you like.

By : Aruman

This video can help you solving your question :)
By: admin