import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.*;
public class ClickCalculator extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
JButton btn1 = new JButton("1");
JButton btn2 = new JButton("2");
JButton btn3 = new JButton("3");
JButton btn4 = new JButton("4");
JButton btn5 = new JButton("5");
JButton btn6 = new JButton("6");
JButton btn7 = new JButton("7");
JButton btn8 = new JButton("8");
JButton btn9 = new JButton("9");
JButton btn10 = new JButton("0");
JButton btn11 = new JButton("C");
JButton btn12 = new JButton("=");
JButton btn13 = new JButton("+");
JButton btn14 = new JButton("-");
JButton btn15 = new JButton("/");
JButton btn16 = new JButton("*");
JLabel display = new JLabel();
public ClickCalculator() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400,200);
makePanel();
setVisible(true);
}
public void makePanel() {
JPanel p1 = new JPanel();
p1.setSize(500,50);
JPanel p2 = new JPanel(new GridLayout(4,4));
p2.add(btn1);
p2.add(btn2);
p2.add(btn3);
p2.add(btn4);
p2.add(btn5);
p2.add(btn6);
p2.add(btn7);
p2.add(btn8);
p2.add(btn9);
p2.add(btn10);
p2.add(btn11);
p2.add(btn12);
p2.add(btn13);
p2.add(btn14);
p2.add(btn15);
p2.add(btn16);
add(p1, BorderLayout.CENTER);
p1.add(display);
add(p2, BorderLayout.SOUTH);
btn1.addActionListener(this);
btn2.addActionListener(this);
btn3.addActionListener(this);
btn4.addActionListener(this);
btn5.addActionListener(this);
btn6.addActionListener(this);
btn7.addActionListener(this);
btn8.addActionListener(this);
btn9.addActionListener(this);
btn10.addActionListener(this);
btn11.addActionListener(this);
btn12.addActionListener(this);
btn13.addActionListener(this);
btn14.addActionListener(this);
btn15.addActionListener(this);
btn16.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
String str = e.getActionCommand();
}
public static void main(String[] args) {
// TODO Auto-generated method stub
ClickCalculator cc = new ClickCalculator();
cc.setTitle("누르는 계산기");
cc.makePanel();
}
}
자바 이클립스 중인데 실행을 하면 숫자입력하는 라벨?
같은게 안떠서 입력이 안되네요...
어디가 문제일까요?