• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Cannot make GridBagLayout contents descend from the top

Resolved: Cannot make GridBagLayout contents descend from the top

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

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.
How it looks
Here is my code (shortened)

Answer:

GridBagLayout will, by default, layout components around the middle of the container.
You can, however, modify the amount of remaining space a component will occupy through the use of weightx and weighty, for example, if you added…
Probably after…
You’d get…
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

If you have better answer, please add a comment about this, thank you!

awt gridbaglayout java layout-manager swing
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How do I use SetWindowText with Unicode in Win32 using PowerShell?

01/04/2023

Resolved: Shopware 400 Status Error “This value is too long. It should have 255 character or less.” When I Try Updating Database Table

01/04/2023

Resolved: Using AWK to count multiple patterns in a file

01/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.