This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
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