문제

I am using both JLabels and JTextFields, and need to be able to truncate my doubles to two decimal places when they are displayed by the application.

How can I perform this truncation, preferably without switching to JFormattedTextFields?

도움이 되었습니까?

해결책

You can use DecimalFormat class. Here is an explanation

다른 팁

Prefer the Swing JFormattedTextField instead; see the Java Tutorial.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top