/*
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
class Main extends JFrame{
JTextField tf1 = new JTextField(13);
JTextField tf2 = new JTextField(11);
public Main() {
setTitle("계산기 프레임");
Container c = getContentPane();
c.setLayout(new BorderLayout());
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JPanel p3 = new JPanel();
c.add(p1, BorderLayout.NORTH);
c.add(p2, BorderLayout.CENTER);
c.add(p3, BorderLayout.SOUTH);
p1.setBackground(Color.GRAY);
p1.setLayout(new FlowLayout());
p2.setBackground(Color.WHITE);
p2.setLayout(new GridLayout(4,4,1,1));
p3.setBackground(Color.YELLOW);
p3.setLayout(new FlowLayout());
p1.add(new JLabel("수식입력"));
p1.add(tf1);
p3.add(new JLabel("계산 결과"));
p3.add(tf2);
String[] arr = {"CE","계산","+","-","x","/"};
for(int i=0;i<=9;i++) {
JButton b = new JButton(Integer.toString(i));
b.addActionListener(new MyActionListener());
p2.add(b);
}
for(int i=0;i<=5;i++){
JButton b = new JButton(arr[i]);
b.addActionListener(new MyActionListener());
p2.add(b);
if(i>=2) {
b.setBackground(Color.CYAN);
}
}
setSize(400,300);
setVisible(true);
}
class MyActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
JButton b = (JButton)e.getSource();
String a = b.getText();
if(a.equals("CE")) { //tf1 글자없애기
tf1.setText("");
}
else if(a.equals("계산")) { //계산결과 tf2에 settext하기
//1. 한자리숫자 연산자 한자리숫자
String sik = tf1.getText();
int op_index = 0;
for(int i=0;i<sik.length();i++) {
if(sik.charAt(i)=='+' || sik.charAt(i)=='-' || sik.charAt(i)=='x' || sik.charAt(i)=='/') {
op_index=i;
break;
}
}
char x = sik.charAt(op_index);
int aa = Integer.parseInt(sik.substring(0,op_index));
int bb = Integer.parseInt(sik.substring(op_index+1,sik.length()));
int res;
if(x=='+') {
res = aa+bb;
}
else if(x=='-') {
res = aa-bb;
}
else if(x=='/') {
res = aa/bb;
}
else {
res = aa*bb;
}
tf2.setText(Integer.toString(res));
}
else {
tf1.setText(tf1.getText()+a);
}
}
}
public static void main(String[] args) {
new Main();
}
}*/
//import java.awt.*;
//import java.awt.event.*;
//import javax.swing.*;
//
//import javax.swing.*;
//public class Main extends JFrame {
// ImageIcon star = new ImageIcon("star.png"); // star.jpg or star.PNG
// private JLabel la = new JLabel(star);
//
// public Main() {
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Container c = getContentPane();
// c.setLayout(null);
// la.setSize(50,20);
// la.setLocation(100,100);
//
// c.add(la);
// la.addMouseListener(new MyMouseListener());
// setSize(250, 250);
// setVisible(true);
// }
//
// class MyMouseListener extends MouseAdapter {
// public void mouseClicked(MouseEvent e) {
// int x = (int)(Math.random()*250);
// int y = (int)(Math.random()*250);
// la.setLocation(x,y);
// }
// }
//
// public static void main(String[] args) {
// new Main();
// }
//}
/* Lable or Button 등에 사진 넣는법
1. flaticon 사이트에서 32px 다운로드하기
2. 왼쪽에 src폴더에 오른쪽 마우스 클릭 -> Properties 클릭 -> Location 맨 오른쪽 버튼 클릭
3. 다운로드한 이미지 2번 위치에 옮기기
4. 이미지 아이콘 객체 생성 ImageIcon star = new ImageIcon("파일이름");
*/
import javax.swing.*;
import java.awt.*;
public class LabelEx extends JFrame {
public LabelEx() {
setTitle("레이블 예제");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
JLabel textLabel = new JLabel("사랑합니다.");
ImageIcon beauty = new ImagizeIcon("images/beauty.jpg");
c.add(textLabel);
c.add(imageLabel);
c.add(label);
setSize(400,600);
setVisible(true);
}
public static void main(String[] args) {
new LabelEx();
}
}