How to make a simple calculator in Java(Net Beans) which can add two numbers.
After Making a calculator design in netbeans you have to apply some event listener on it. So i m giving the code you have to write it in the eventlistener on the add button.
<——Start——>
float num1,num2,result;
num1=Float.parseFloat(txtfield1.getText());
num1=Float.parseFloat(txtfield2.getText());
//Now we can perform the addition.
result = num1+num2;
txtfieldresult.setText(String.valueOf(result));
<—–End—–>
Remeber You have to change the variable names of text field to txtfield1,txtfield2 and txtfieldresult .
after completing this you have to press shift +F6 and the program will be run..













