Article View: borland.public.jbuilder.java.language
Article #17228Re: Format float in Textfield
From: Vasudevan Srinivasan
Date: Fri, 04 Dec 1998 00:00
Date: Fri, 04 Dec 1998 00:00
46 lines
2501 bytes
2501 bytes
--------------67B4444F6A931195AE9F1465
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Hi Mein,
1. One way is to extend the TextField class and handle events KeyPressed
and KeyReleased.
2. Extend DecimalFormat class and use methods
setMaximumFractionDigits(); for commas, add a method like "GermanFormat"
and StringTokenize the number and append commas at proper positions.
Mein Name wrote:
> Please! 1) How can I force a textfield only to accept numeric
> values?2) How to format a float to a numeric value, e.g. USD 30.000,50
> (german like)? Now we use textfield1.setText("" + floatvar); Thanks
> for help Timo Schn๏ฟฝlzer
--------------67B4444F6A931195AE9F1465
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<BODY BGCOLOR="#FFFFFF">
Hi Mein,
<P>1. One way is to extend the TextField class and handle events KeyPressed
and KeyReleased.
<BR>2. Extend DecimalFormat class and use methods setMaximumFractionDigits();
for commas, add a method like "GermanFormat" and StringTokenize the number
and append commas at proper positions.
<BR>
<P>Mein Name wrote:
<BLOCKQUOTE TYPE=CITE> <FONT COLOR="#000000"><FONT SIZE=-1>Please!</FONT></FONT> <FONT COLOR="#000000"><FONT SIZE=-1>1)
How can I force a textfield only to accept numeric values?</FONT></FONT><FONT COLOR="#000000"><FONT SIZE=-1>2)
How to format a float to a numeric value, e.g. USD 30.000,50 (german like)?</FONT></FONT><FONT COLOR="#000000"><FONT SIZE=-1>
Now we use textfield1.setText("" + floatvar);</FONT></FONT> <FONT COLOR="#000000"><FONT SIZE=-1>Thanks
for help</FONT></FONT> <FONT COLOR="#000000"><FONT SIZE=-1>Timo Schnölzer</FONT></FONT></BLOCKQUOTE>
</BODY>
</HTML>
--------------67B4444F6A931195AE9F1465--
Technical Details
Message-ID:
<3667FE35.223D2C9D@netrisk.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<740l57$nn32@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f74b3,355181bd00043dfe,start X-Google-Attributes: gidf74b3,public From: Vasudevan Srinivasan <vasudevan@netrisk.com> Subject: Re: Format float in Textfield Date: 1998/12/04 Message-ID: <3667FE35.223D2C9D@netrisk.com> X-Deja-AN: 418638581 References: <740l57$nn32@forums.borland.com> To: Mein Name <MeinAlias@T-Online.de> Content-Type: multipart/alternative; boundary="------------67B4444F6A931195AE9F1465" Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language