Simple Add in Java | Net Beans

Posted by admin On January - 7 - 2010

How to make a simple calculator in Java(Net Beans) which can add two numbers.

calculator Simple Add in Java | Net Beans

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..

VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)
Share with others:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • StumbleUpon
  • Twitter
  • Twitthis
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Leave a Reply

Help Pakistan's Flood Victims
Ad-Space Available
Our Sponsor

About Me

I will tell you Later

Twitter

    Photos

    Kis galiKabristanDSC09340DSC09302