import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
/*public class Main extends JFrame{
private String [] fruits = {"학생","001 - APL","002 - BAN"
,"003 - KWI","004 - MNG", "005 - PEA", "006 - PCH ",
"007 - BER" , "008 - STB" , "009 - BAB","010 - BLB" };
private String [] persons = {"점수","A+(100)","A(99-91)","B+(90-81)","B(80-75)",
"B-(74-60)","C(59-51)","C-(50-46)","D(46-36)","D-(35-21)","F(20-0)"};
public Main(){
setTitle("뚱띠 0110012");
setVisible(true);
int i;
Container c = getContentPane();
c.setLayout(new FlowLayout());
JComboBox<String> strCombo = new JComboBox<String>(fruits);
c.add(strCombo);
JComboBox<String> pCombo = new JComboBox<String>();
for(i = 0;i<persons.length;i++) {
pCombo.addItem(persons[i]);
}
c.add(pCombo);
setSize(300,300);
}
public static void main(String[] args) {
new Main();
}
}
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
JLabel la = new JLabel("150");
JSlider s = new JSlider(JSlider.HORIZONTAL, 100, 200, 150);
public Main() {
setTitle("뚱띠 0110012");
setVisible(true);
int i;
Color n = new Color(0, 0, 102);
Container c = getContentPane();
c.setLayout(new FlowLayout());
la.setForeground(n);
s.setPaintLabels(true);
s.setPaintTicks(true);
s.setPaintTrack(true);
s.setMinorTickSpacing(10);
s.setMajorTickSpacing(20);
s.setForeground(n);
s.addChangeListener(new Change());
c.add(s);
c.add(la);
setSize(300, 300);
}
class Change implements ChangeListener {
public void stateChanged(ChangeEvent e) {
int h = s.getValue();
la.setText(Integer.toString(h));
}
}
public static void main(String[] args) {
new Main();
}
}*/
import java.util.*;
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
JTextField uptf = new JTextField(20);
public Main() {
setTitle("계산기 0.5버전");
setSize(500, 500);
setVisible(true);
Container c = getContentPane();
c.setLayout(new BorderLayout());
JPanel up = new JPanel();
JPanel ce = new JPanel();
JPanel dn = new JPanel();
up.setBackground(Color.darkGray); // 배경색 설정
c.add(up, BorderLayout.NORTH); // 컨테이너에 부착
JLabel nla = new JLabel("수식");
nla.setForeground(Color.WHITE);
up.add(nla);
up.add(uptf);
//////////////////////////
ce.setBackground(Color.LIGHT_GRAY);
c.add(ce, BorderLayout.CENTER);
ce.setLayout(new GridLayout(4, 4));
for (int i = 0; i < 10; i++) {
JButton u=new JButton(Integer.toString(i));
ce.add(u);
u.addActionListener(new Act());
}
JButton ob = new JButton("C/CE(AC)");
ob.setForeground(Color.lightGray);
ce.add(ob);
JButton tb = new JButton("Cal");
tb.setForeground(Color.GREEN);
ce.add(tb);
JButton hb = new JButton("+");
ob.setForeground(Color.RED);
hb.addActionListener(new Act());
ce.add(hb);
JButton fb = (new JButton("-"));
fb.addActionListener(new Act());
fb.setForeground(Color.YELLOW);
ce.add(fb);
ce.add(new JButton("×"));
ce.add(new JButton("÷"));
////////////////////////
dn.setBackground(Color.darkGray);
c.add(dn, BorderLayout.SOUTH);
JLabel nnla = new JLabel("결과");
nnla.setForeground(Color.WHITE);
dn.add(nnla);
dn.add(new JTextField(20));
//다음시간에 추가할것 : 곱하기,나누기버튼, cal눌렀을때 계산결과 출력하기
/////////////////
}
class Act implements ActionListener {
public void actionPerformed(ActionEvent e) {
JButton b = (JButton)e.getSource();
uptf.setText(uptf.getText()+b.getText());
}
}
public static void main(String[] args) {
new Main();
}
}



