Re: Parsing or Casting a JtextField? Help requested....
- From: Tamer Higazi <no@xxxxxxx>
- Date: Wed, 28 Feb 2007 17:34:18 +0200
From the runtime the values in a JTextField have to be assigned to avariable with the following datatype:
short
byte
int
I don't know how to do that!
For any help
Thank you
Tamer
Eric Smith schrieb:
Tamer Higazi <no@xxxxxxx> writes:.
I have a JTextField which receives at runtime a value. Now this value
has to be inserted with a specialtype (not text) in a database.
In the java chat somebody told me that I have to parse. I know only on
C++ that the conversion a value from one datatype to one other has to be
casted.
What kind of value? A numeric value? A string? Parsed how?
You get the String value from the JTextField by using the getText() method.
If you want to treat it as an integer, you can pass that String to
Integer.parseInt() or Integer.valueOf(). Those will throw a
NumberFormatException if the String can't be parsed as an integer.
There are similar methods Long.parseLong(), Long.valueOf(),
Short.parseShort(), Short.valueOf(), Float.valueOf(), and
Double.valueOf().
- References:
- Parsing or Casting a JtextField? Help requested....
- From: Tamer Higazi
- Re: Parsing or Casting a JtextField? Help requested....
- From: Eric Smith
- Parsing or Casting a JtextField? Help requested....
- Prev by Date: Re: eclipse
- Next by Date: JButton sizing ?
- Previous by thread: Re: Parsing or Casting a JtextField? Help requested....
- Next by thread: eclipse
- Index(es):