I'm want to output a calculation to a JLabel. Example:
double num1 = 14; double num2 = 3; double ans; ans = num1/num2; JLabel jl = new JLabel(); add(jl); jl.setText("The Answer is: " + ans);
Currently the answer for this will be 4.666666667. Now if this was a System.out statement I could have just done:
System.out.printf("The answer is: %.2f", ans);. However, I can't. So what can I do to make the number diplayed in the JLabel look like 4.66.