Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / July 2004

Tip: Looking for answers? Try searching our database.

Entering values in a JTable

Thread view: 
James Gralton - 21 Jul 2004 12:39 GMT
Hi,

I have a JTable and want to enter probabilities in to it. Most of the time
this works fine but I have recently noticied that if I try to enter small
values like this 0.00002 when the cell loses focus the value in the cell
becomes 0. When focus returns to the cell it correctly displays 2.0E-5.

How can I make it so 2.0E-5 would always appear or even 0.00002 but not 0 as
that is wrong. Obviously the values in the JTables data array are correct
but they arn't displaying correctly.

I have tried implementing a number of DefautCellRenderers, CellRender ....

Any help or hints appreciated.

James Gralton
Tor Iver Wilhelmsen - 21 Jul 2004 14:58 GMT
> I have a JTable and want to enter probabilities in to it. Most of the time
> this works fine but I have recently noticied that if I try to enter small
> values like this 0.00002 when the cell loses focus the value in the cell
> becomes 0. When focus returns to the cell it correctly displays 2.0E-5.

This indicates that the component used by the CellEditor and the
component used by the CellRenderer formats numbers differently.

> How can I make it so 2.0E-5 would always appear or even 0.00002 but not 0 as
> that is wrong. Obviously the values in the JTables data array are correct
> but they arn't displaying correctly.

Write your custom CellRenderer to format it correctly.

> I have tried implementing a number of DefautCellRenderers, CellRender ....

How did you set the text in the interface's rendering method?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.