Home > Back-end >  Cannot make GridBagLayout contents descend from the top
Cannot make GridBagLayout contents descend from the top

Time:06-16

I have a JFrame with five buttons added to the contents panel. I intended for the X axis to begin at the very top of the frame, however, when the frame is resized the contents are shifted towards the middle. How do I maintain all of the components floating to the top.

enter image description here

Now, personally, I'd consider using compound layouts, as finding the "last" y position might not always be feasible

See How to Use GridBagLayout for more details

  • Related