Decimal Field to set the integral part and fractional part

40 views
Skip to first unread message

Wolfgang Schele

unread,
Apr 14, 2013, 5:00:34 PM4/14/13
to jfxtra...@googlegroups.com
Hi,

I need an implementation of a javafx decimal field were I can set the integral part and fractional part like I spepcify a databse column.

e.g. a DB-Field is specified as Number(5,2) .. then I will e.g. init a decimal field to correspond with this DB-Field...

DecimalField df = new DecimalField(5,2);

or for a pure Integer DB-Field with the length fives:

DecimalField df = new DecimalField(5,0) or DecimalField df = new DecimalField(5) ;

Has anybody of you an implemtation like this or how can I configure the decimal field of JFXtras to achieve this?

best regards
ws

Thomas Bolz (GMail)

unread,
Apr 15, 2013, 2:19:19 AM4/15/13
to jfxtra...@googlegroups.com
Hi Wolfgang,

it isn't directly possible, but as the BigDecimalField is initialized with a BigDecimal which can be initialized with a String, you could achieve that by the following two steps:

        BigDecimal number = new BigDecimal(5+"."+123);
        BigDecimalField field = new BigDecimalField(number);

which is not very nice, but does the job.
Binding those values or setting them separately after initialization is not possible (or at least I have no instant idea how).

Regards

Thomas
--
You received this message because you are subscribed to the Google Groups "JFXtras Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jfxtras-user...@googlegroups.com.
To post to this group, send email to jfxtra...@googlegroups.com.
Visit this group at http://groups.google.com/group/jfxtras-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Wolfgang Schele

unread,
Apr 17, 2013, 3:00:39 AM4/17/13
to jfxtra...@googlegroups.com
I check this example in a small app and it don't work...afterwards I can put numbers into the field like:

123,4567 --> with 4 fractionals...so...when I save this to my database I get an error...or did I things wrong?

Thomas Bolz (GMail)

unread,
Apr 17, 2013, 3:03:59 PM4/17/13
to jfxtra...@googlegroups.com
Hi Wolfgang,

hmmh, I don't know if I understood your use case entirely then, what exactly did not work? 
In any case my understanding is, that you want to map some (arbitrary?) sort of number data structure that comes from a DB to a BigDecimal and back and offer the user to edit it in the BigDecimalField. This is almost certainly not directly supported by the BigDecimalField but the idea that comes immediately to my mind is to implement some sort of a Mapper class that maps both data structures back and forth. If you need that other data structure in a bound property then I would extend the BigDecimalField if not do it on request in some event handler.
Does that help?

Cheers

Thomas
Reply all
Reply to author
Forward
0 new messages