this my GUI I designed by Netbean Builder
description http://up07.s-oman.net/1hGDmMy.png
I want when the user click calculate button it will add Rate Of Interest with Laon Amount and display total in total TextFeild .
this my calculate method
public void calculate(int b){
int num1 = (Integer.parseInt(jTextField2.getText()));
int num2 = (Integer.parseInt(jTextField4.getText()));
b=num1+num2;
}
this code in button calculate
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
calculate(b);
}
and this code in total TextField
private void jTextField6ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField6.setText(String.valueOf(b));
}
I got nothing When I tried So what the wrong??
I don't see the point of a the textfield that displays the result, needing an ActionListener
. Try something like this, setting the text in the calculate
method
public voi calculate(){
int result;
int num1 = (Integer.parseInt(jTextField2.getText()));
int num2 = (Integer.parseInt(jTextField4.getText()));
jTextField6.setText(String.valueOf(num1 + num2));
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
calculate();
}
I have idea what b
does, but I'm assuming you're trying to pass it by reference which won't work, so I took it out.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.