rendered paste body public void actionPerformed(ActionEvent e){
if(e.getSource() == but1)
{
addDigitToDisplay(but1);
}
else if(e.getSource() == but2)
{
addDigitToDisplay(but2);
}
else if(e.getSource() == but3)
{
addDigitToDisplay(but4);
}
else if(e.getSource() == but5)
{
addDigitToDisplay(but5);
}
else if(e.getSource() == but6)
{
addDigitToDisplay(but6);
}
else if(e.getSource() == but7)
{
addDigitToDisplay(but7);
}
else if(e.getSource() == but8)
{
addDigitToDisplay(but8);
}
else if(e.getSource() == but9)
{
addDigitToDisplay(but9);
}
else if(e.getSource() == but0)
{
addDigitToDisplay(but0);
}
}
void setDisplayString(String s){
LabelOutPut.setText(s);
}
String getDisplayString (){
return LabelOutPut.getText();
}
void addDigitToDisplay(int digit){
if (clearOnNextDigit)
setDisplayString("");
String inputString = getDisplayString();
if (inputString.indexOf("0") == 0){
inputString = inputString.substring(1);
}
if ((!inputString.equals("0") || digit > 0) && inputString.length() < MAX_INPUT_LENGTH){
setDisplayString(inputString + digit);
}
displayMode = INPUT_MODE;
clearOnNextDigit = false;
}