728x90
반응형
package gui;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class {
public static void main(String[] args) {
JFrame f = new JFrame("GridLayout Example");
GridLayout grid = new GridLayout(3, 5);
// 여백 설정
grid.setHgap(5); // Horizontal gap
grid.setVgap(5); // Vertical gap
for (int i = 0; i < 15; ++i) {
f.add(new JButton("button" + i));
}
f.setLayout(grid);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setBounds(100, 100, 500, 300);
f.setVisible(true);
}
}
728x90
반응형
'JAVA > Swing' 카테고리의 다른 글
[JAVA] FlowLayout (0) | 2023.05.02 |
---|---|
[JAVA] JPanel (0) | 2023.05.02 |
[JAVA] JComboBox (0) | 2023.05.02 |
[JAVA] JRadioButton (0) | 2023.05.02 |
[JAVA] JCheckBox (0) | 2023.05.02 |