Resize GUI?

My question is simple, but I cannot find an exact solution for this. I am trying to write a program with the Java GUI, I am using the absolute layout for my program, and I am setting the frame frames (100, 100, 450, 300). When I run the program and make it full-screen, the components remain in their places. I want them to be automatically replaced depending on the screen size. All props are accepted, thanks! enter image description here

enter image description here

+4
source share
1 answer

The solution is pretty simple. You declare, "I use absolute layout for my program and I set frame bounds(100, 100, 450, 300)."Do not do this. Use layout managers to help you position your components.

, BorderLayout JPanel JButton new GridLayout(0, 1, 0, 5), JPanel (1 , , 5 ), JPanel main BorderLayout.LINE_END , , , . , setBounds(...) , , , , , .

+6

Source: https://habr.com/ru/post/1588895/


All Articles