import java.awt.GridLayout;Output
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class GridLayoutExample extends JFrame{
GridLayout grid = new GridLayout(3, 2);
public GridLayoutExample(){
JFrame 프레임 = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(250,250);
frame.setVisible(true);
JPanel 패널 = new JPanel();
frame.setContentPane(패널);
panel.setLayout(그리드);
panel.add(new JButton("1"));
panel.add(새 JButton("2"));
panel.add(new JButton("3"));
panel.add(new JButton("4"));
panel.add(new JButton("5"));
panel.add(new JButton("6"));
}
public static void main(String[] args) {
new GridLayoutExample();
}
}
public gridLayout (int line, int col, int hgap, int vgap);
grid.setHgap(10);
grid.setVgap(15);
Please disable your ad blocker and refresh the window to use this website.