자바 gui swing 4

(。◠ ◠。)·2022년 6월 8일
0

public class K_PanelTest extends JFrame{
	public K_PanelTest() {
		
		setTitle("Container & Component");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setLayout(null);
		setBackground(Color.gray);
		
		JPanel p1 = new JPanel();
		p1.setSize(150, 150);
		p1.setLocation(10,10);
		p1.setBackground(Color.YELLOW);
		p1.add(new JLabel("JPanel-1 : 150 * 150"));
		p1.add(new JCheckBox("C# JCheckBox"));
		p1.add(new JCheckBox("C++ JCheckBox"));
		add(p1); //add안하면 안나옴
		
		JPanel p2 = new JPanel();
		p2.setSize(150,150);
		p2.setLocation(170,10);
		p2.setBackground(Color.GREEN);
		p2.add(new JLabel("JPanel-2 : 150 * 150"));
		add(p2);
		
		JButton btn = new JButton("OK");
		
		btn.setLocation(130, 170);
		btn.setSize(70, 30);
		add(btn);
		
		setSize(350, 250);
		setResizable(false);
		setVisible(true);
	}
	public static void main(String[] args) {
		new K_PanelTest();
	}

}
profile
화이탱!

0개의 댓글

관련 채용 정보