Width: 100% Without Scrollbars

That’s because you’re using position: absolute. Instead of using: width: 100%; margin-right: 10px; margin-left: 10px you should use: left: 10px; right: 10px That will make your element take the full width available, with 10px space on the left and right.

Can I add a component to a specific grid cell when a GridLayout is used?

No, you can’t add components at a specific cell. What you can do is add empty JPanel objects and hold on to references to them in an array, then add components to them in any order you want. Something like: int i = 3; int j = 4; JPanel[][] panelHolder = new JPanel[i][j]; setLayout(new GridLayout(i,j)); … Read more

tech