0
버튼을 클릭하여 작동하는 계산기 프로그램이 있습니다. 텍스트를 문자열에 추가 한 다음 나중에 계산을 수행하기 위해 double로 변환하고 변환합니다.키 트리거 액션 리스너
but1.addActionListener(this);
if (source==but1) // Number buttons shows the text to display
{
text.append("1");
}
public double number_convert() // Converts the string back to double
{
double num1;
String s;
s = text.getText();
num1 = Double.parseDouble(s); // creating a double from the string value.
return num1; //returns value
}
키보드 키로 ActionListener
을 실행해야합니다. 어떤 아이디어가 이것을 어떻게?
모든 것이 계산기에서 작동합니다. 키보드 키를 눌렀을 때 버튼을 실행하는 방법 만 있으면됩니다.