본문 바로가기

명품자바

[명품자바] 오픈 챌린지 9

import javax.swing.*;
import java.awt.*;

public class Chapter9 extends JFrame {
	public Chapter9() {
		setTitle("openChallenge 9");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		Container c = getContentPane();
		
		c.add(new NorthPanel(), BorderLayout.NORTH);
		c.add(new CenterPanel(), BorderLayout.CENTER);
		
		setSize(400, 500);
		setVisible(true);
	}
	
	static public void main(String [] args) {
		new Chapter9();
	}
}

class NorthPanel extends JPanel {
	NorthPanel() {
		setBackground(Color.LIGHT_GRAY);
		
		setLayout(new FlowLayout(FlowLayout.CENTER, 5 ,5));
		
		add(new JButton("open"));
		add(new JButton("Read"));
		add(new JButton("Close"));
	}
}

class CenterPanel extends JPanel {
	CenterPanel() {
		JLabel lb;
		
		setLayout(null);
		
		lb = new JLabel("Hello");
		lb.setLocation(100, 50);
		lb.setSize(200,20);
		add(lb);
		
		lb = new JLabel("Love");
		lb.setLocation(10, 200);
		lb.setSize(200,20);
		add(lb);
		
		lb = new JLabel("Java");
		lb.setLocation(239, 400);
		lb.setSize(200,20);
		add(lb);
	}
}

'명품자바' 카테고리의 다른 글

[명품자바] 오픈 챌린지 6  (0) 2024.06.10
[명품자바] 오픈 챌린지 5  (0) 2024.06.10
[명품자바] 오픈 챌린지 4  (0) 2024.06.10
[명품자바] 오픈 챌린지 3  (0) 2024.06.10
[명품자바] 오픈 챌린지 10  (0) 2024.06.09