I used a borderLayout, added a JLabel in north then added a jpanel into the center with a grid layout (8,1) and then added two empty panels to make the extra spaces on the far left and right. So my question, is there another way to make these spaces? Frame I want
Frame I made
SOURCE: make spaces in this JFrame
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
use the following code
public class Testing1 extends javax.swing.JFrame { public Testing1() {
EmptyBorder panelBorder = new EmptyBorder(10, 10, 10, 10); jPanel1.setBorder(panelBorder); EmptyBorder border = new EmptyBorder(5, 20, 5, 20); LineBorder line = new LineBorder(Color.blue, 2, true); CompoundBorder compound = new CompoundBorder(line, border); for (int i = 0; i <12; i++) { JLabel label = new JLabel(“Label” + i); label.setBorder(compound); // label.setBounds(13, 100, 100, 50); jPanel1.add(label); } return jPanel1; } SOURCE: JFRAME