자바 스윙 계산기 관련 질문 입니다 ..
바르고
자바 스윙으로 계산기 만들기
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class calculator extends jframe {
jbutton one, two, three, four, five, six, seven, eight;
jbutton nine, zero, add, sub, multi, effect, clear, divi;
jtextfield phone;
public calculator() {
super(ju by 1.0);
setresizable(false);
setsize(293, 280);
getcontentpane().setlayout(null);
phone = new jtextfield();
phone.setsize(270, 30);
phone.setlocation(10, 20);
getcontentpane().add(phone);
one = new jbutton(1);
one.setsize(60, 40);
one.setlocation(15, 60);
getcontentpane().add(one);
two = new jbutton(2);
two.setsize(60, 40);
two.setlocation(80, 60);
getcontentpane().add(two);
three = new jbutton(3);
three.setsize(60, 40);
three.setlocation(145, 60);
getcontentpane().add(three);
four = new jbutton(4);
four.setsize(60, 40);
four.setlocation(15, 105);
getcontentpane().add(four);
five = new jbutton(5);
five.setsize(60, 40);
five.setlocation(80, 105);
getcontentpane().add(five);
six = new jbutton(6);
six.setsize(60, 40);
six.setlocation(145, 105);
getcontentpane().add(six);
seven = new jbutton(7);
seven.setsize(60, 40);
seven.setlocation(15, 150);
getcontentpane().add(seven);
eight = new jbutton(8);
eight.setsize(60, 40);
eight.setlocation(80, 150);
getcontentpane().add(eight);
nine = new jbutton(9);
nine.setsize(60, 40);
nine.setlocation(145, 150);
getcontentpane().add(nine);
zero = new jbutton(0);
zero.setsize(60, 40);
zero.setlocation(80, 195);
getcontentpane().add(zero);
// 사칙연산
add = new jbutton(+);
add.setsize(60, 40);
add.setlocation(210, 60);
getcontentpane().add(add);
sub = new jbutton(-);
sub.setsize(60, 40);
sub.setlocation(210, 105);
getcontentpane().add(sub);
multi = new jbutton(*);
multi.setsize(60, 40);
multi.setlocation(210, 150);
getcontentpane().add(multi);
divi = new jbutton(/);
divi.setsize(60, 40);
divi.setlocation(210, 195);
getcontentpane().add(divi);
effect = new jbutton(=);
effect.setsize(60, 40);
effect.setlocation(145, 195);
getcontentpane().add(effect);
clear = new jbutton(c);
clear.setsize(60, 40);
clear.setlocation(15, 195);
getcontentpane().add(clear);
setdefaultcloseoperation(exit_on_close);
setvisible(true);
}
public static void main(string[] args) {
new calculator();
}
}
아직 까지 오류 사항은 없고요 ..
일단 기본 틀을 제가 만들어는데요 ..
여기다가 사칙연산 계산을 하고 싶은데 이벤트 사용 해서 클릭시 값 을 집어 넣어 계산 하고
싶은데 계속 오류가 나네요 개념이나 아님 참조 사항좀 알려 주세욧 ..