views:

41

answers:

2

I am using both JLabels and JTextFields, and need to be able to truncate my doubles to two decimal places when they are outputted to the application. What is the easiest way of doing this (preferably without switching to JFormattedTextFields)?

Thanks,

badPanda :D

+2  A: 

You can use DecimalFormat class. Here is an explanation

Enrique
+1  A: 

Prefer the Swing JFormattedTextField instead; see the Java Tutorial.

rhu
didn't read your question fully ....
rhu