wood burning stoves*
The moose likes Java in General and the fly likes textfield entry Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "textfield entry" Watch "textfield entry" New topic
Author

textfield entry

Chris Fetterley
Ranch Hand

Joined: May 13, 2003
Posts: 51
I was wondering if there was an easy way to have textfields deslected until data was entered into the one above it, is there an easy way to do this?
John Lee
Ranch Hand

Joined: Aug 05, 2001
Posts: 2545
Originally posted by Chris Fetterley:
I was wondering if there was an easy way to have textfields deslected until data was entered into the one above it, is there an easy way to do this?

i would use event model to select the textfield when the one above it has data input.
Chris Fetterley
Ranch Hand

Joined: May 13, 2003
Posts: 51
could it be done with a bunch of if else statements also?
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Originally posted by Chris Fetterley:
I was wondering if there was an easy way to have textfields deslected until data was entered into the one above it, is there an easy way to do this?

Sure, you just start with your label font grayed out and the TextFeild set to setEditable(false);.
Then put a TextListener on the field above it, and in the textValueChanged method, check to make sure that a real value was entered. You probably want to make sure that the length of the entered text is at least one. Then in that method change the font of the label to black and do a setEditable(true) on the blocked componenent.
You probably do not want to be re-setting this with every letter that is typed, so you might want to start out with a preliminary check to see if the target field is already editable and then just skip the rest.


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: textfield entry