Search code examples
javaswingnetbeansjtextfield

Adding jTextfields Values in java using netbeans


i want to add the values of two jTextfield and show the results in another jTextfield. how do i do this programatically.

example i have jTextfield called "MonthlyDep" and another jTextfield called "NewAcc"

how do add the values of the two and show it in a jTextfield called "rslts"

Thank You.


Solution

  • in button click (ActionListener) write this code..

    rslts.setText((Integer.parseInt(MonthlyDep.getText())+Integer.parseInt(NewAcc.getText()))+"");