Hi I am using a BoxLayout to stack JPanels on top of each other (BoxLayout.Y_AXIS), for example if my parent JPanel is of height 500 pixels and I add two child panels to it both of height 100 pixels. The BoxLayout stretches them so that together they occupy the the 500px space. Does anyone know how to disable this feature?
Hi I am using a BoxLayout to stack JPanel s on top of each
Share
Use GridBagLayout instead. You have much more control over your UI.
But if you want to use BoxLayout still, and don’t want them to stretch, you can check out using invisible component fillers like rigid areas, glue and fillers.