Wrox Programmer Forums
|
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 22nd, 2003, 08:50 AM
Registered User
 
Join Date: Jul 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to flaviostz
Default JText

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.

Flávio de Souza
======================
flaviostz@yahoo.com.br
ICQ: 78458203
======================
 
Old July 31st, 2003, 12:11 AM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to shortynelson Send a message via Yahoo to shortynelson
Default

Hi, I am a beginner. I am not sure if the below point I give is the most suitable one. Anyone plesae point out if it is wrong.

Flaviostz, if I were you, I will add a static boolean variable. In the textfield, add one actionListener that will always detect if anything has been keyed into it, and validate the input. At the same time, adjust the boolean variable, for example, to True if something has been keyed.

Maybe that can help you?

Nelson Chan
 
Old July 31st, 2003, 12:56 AM
Authorized User
 
Join Date: May 2003
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
Plz. go through the following url there is an example provided for TexteField's this has a solution to your problem

http://java.sun.com/docs/books/tutor...tml#validation

Regards

Yashraj Chauhan
Java\J2EE Specialist
Wiley Support Team
 
Old August 2nd, 2003, 02:31 PM
Registered User
 
Join Date: Jul 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to flaviostz
Default

Thanks for the feed back guys!
It worked just fine!


:D

Flávio de Souza
======================
flaviostz@yahoo.com.br
ICQ: 78458203
======================





Similar Threads
Thread Thread Starter Forum Replies Last Post
Validating Text in JText javanewbie05 Java GUI 3 June 23rd, 2005 08:35 AM
JText validation flaviostz J2EE 1 July 26th, 2003 04:28 AM





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