import javax.swing.*;
import java.awt.*;
public class Main extends JFrame{
public Main() {
setTitle("GridLayout Sample");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridLayout grid = new GridLayout(4,2);
grid.setVgap(5);
Container c=getContentPane();
c.setLayout(grid);
c.add(new JLabel(" 이름"));
c.add(new JTextField(""));
c.add(new JLabel(" 학번"));
c.add(new JTextField(""));
c.add(new JLabel(" 학과"));
c.add(new JTextField(""));
c.add(new JLabel(" 과목"));
c.add(new JTextField(""));
setSize(300,200);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}*/
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame{
public Main() {
setTitle("Null Container Sample");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c= getContentPane();
c.setLayout(null);
JLabel la = new JLabel("Hello, press buttons!");
la.setLocation(130, 50);
la.setSize(200,20);
c.add(la);
for(int i=1;i<=9;i++) {
JButton b=new JButton(Integer.toString(i));
b.setLocation(i*15, i*15);
b.setSize(50, 20);
c.add(b);
}
setSize(300,200);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}