I have created a form in Swing with 10 components (5 labels and 5 textfields), using Gridbaglayout.
When my screen resolution changes, the separation between the components is not changing. Why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
GridBagLayout uses pixels as the unit of measure. You can use java.awt.Toolkit.getScreenResolution() to get the pixel density and then scale your spacing accordingly. You also might find java.awt.GraphicsConfiguration.getNormalizingTransform() useful; it allows you to work in a coordinate system where 72 units is 1 physical inch.