Issue
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
try{
int num1=Integer.parseInt(jTextField4.getText());
int num2=Integer.parseInt(jTextField5.getText());
int result=num1*num2;
jTextField6.setText(result);
} catch(NumberFormatException e) {
}
}
Here's the code. I'm getting error on " jTextField6.setText(result);" . As you can see i gave some bolt effect for you can see normally. What should i use instead of this ? This error coming out
"method setText in class JTextComponent cannot be applied to given types; required: String found: int reason: actual argument int cannot be converted to String by method invocation conversion"
I'm trying to do: Take text from jtextfield4, take from jtextfield5 too. And multpilicate them and show the result in the jtextfield6. This is not fully automatic. I'm writing this code for a button. I'm waiting your advices. If you want more codes, graphics etc. Just leave a comment
Solution
I assume setText need to have text set. How about
jTextField6.setText(""+result);
Answered By - Peter Lawrey
Answer Checked By - Marie Seifert (JavaFixing Admin)