Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 23rd, 2003, 01:27 PM
Registered User
 
Join Date: Jul 2003
Location: , , Brazil.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to flaviostz
Default JText validation

I am writing a code to make a calculation. I use two JText inputs to make a division. However I would like to check if the JText is empty, or is equal to "" before make the calculation. Besides that I would like to check if it is equal zero.

What I really want to do is to check if the JText is not empty or has any space on it or if the value is different from 0. I want to use in the calculation only valid numbers.

Can you help me with that?

Thanks and regards,



Flávio de Souza
======================
flaviostz@yahoo.com.br
ICQ: 78458203
======================
Reply With Quote
  #2 (permalink)  
Old July 26th, 2003, 04:28 AM
Registered User
 
Join Date: Jul 2003
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

What u can do is as follows:

First get the data from the JTextField:
say,
String value = text.getText();

if(value.length() > 0)
{
    try
    {
        int i = Integer.parseInt(value);
        // do further calculations
    }
    catch(ArthimeticException aE)
    {
         // throw appropriate Error msg
    }
}
else
{
    // throw appropriate Error msg
}



Regards,

Balaji
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Standalone validation + web form validation morbo Struts 0 August 19th, 2008 04:02 AM
Validation using Validation Framework kalyangvd Struts 1 January 2nd, 2008 06:53 AM
Validating Text in JText javanewbie05 Java GUI 3 June 23rd, 2005 08:35 AM
validation crmpicco Javascript How-To 2 February 4th, 2005 05:10 AM
JText flaviostz Java GUI 3 August 2nd, 2003 02:31 PM



All times are GMT -4. The time now is 10:11 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.