We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

I have a JTable that has a column of class Double.  How do I format it so there is always at least 1 number after the decimal place?

gdkinney_2
gdkinney_2 asked
on
Medium Priority
1,431 Views
Last Modified: 2013-12-29
I have a JTable that has a column of class Double.  How do I format it so there is always at least 1 number after the decimal place for the numbers in the column of Doubles.  I have a Table Model that extends AbstractTableModel for the JTable.

For example if I have
200
200.3
300.33

in a column in my JTable they will display as

200.0
200.3
300.33
to the user?

Thanks
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016

Commented:
You would need to use a custom TableCellRenderer
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:

Author

Commented:
Objects

I used the code that your link provides and it seems to work.  Before I used the CellRenderer my numbers in my cells were right justified but now they are left justified can I make them right justified again?

Thanks
CERTIFIED EXPERT
Top Expert 2016
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Java Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Both experts gave valuable advice that helped solve my problem.  Thank You!
CERTIFIED EXPERT
Top Expert 2016

Commented:
:-)
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
(-:
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.