Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1062
| From | "Tamer Higazi" <tamer.higazi@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: Parsing or Casting a |
| Message-ID | <45e5a0fa$0$23137$9b4e6d93@newsspool1.arcor-online.net> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <qh4pp6eneq.fsf@ruckus.brouhaha.com> |
| Date | 2011-04-27 15:31 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui From the runtime the values in a JTextField have to be assigned to a variable 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@mail.de> 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(). --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar
Parsing or Casting a Jtex "Tamer Higazi" <tamer.higazi@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
Re: Parsing or Casting a "Badshah" <badshah@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
Re: Parsing or Casting a "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
Re: Parsing or Casting a "Eric Smith" <eric.smith@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
Re: Parsing or Casting a "Tamer Higazi" <tamer.higazi@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
Re: Parsing or Casting a "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
Re: Parsing or Casting a "Eric Smith" <eric.smith@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
csiph-web