aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Swing HELP! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing HELP!" Watch "Swing HELP!" New topic
Author

Swing HELP!

Janine Williams
Greenhorn

Joined: Jan 01, 2001
Posts: 6
Hi,
I have a problem, I'm working on an application that has several text labels, the way that I want the labels to be coded is so that if the text area for the corresponding label NEEDS to be filled it will appear red, and once the required information has been filled in then the label will change to black.
Please help!
Janine
Sayed Ibrahim Hashimi
Ranch Hand

Joined: May 17, 2001
Posts: 148
I'm not exactly what you are trying to do but I think I have an idea. I'm assuming that the user is going to click a button when he is done? If this is the case why don't you set up two arrays, on of labels(JLabels) and one of textFields(JTextFields). The indeices should correspond to each other. What I mean is if you have a label that says: "Name" and a textField for the user to fill in then label[0] should be the "Name" label and textField[0] should be the textField corresponding to it. Then just go with a for loop and check to make sure all textFields are filled in:
for( int i = 0; i < size; i++)
{
if( ( textField[i].getText() ).equals(null) ) //or textField[i].getText() == null;
{
label[i].setForeground(Color.red);
label[i].setText("Please Fill this in");
}
}
If you want to check for specific information in each textField than this will be a little harder.
I didn't have time to compile this for errors but I think it'll work
Hope this helps

SCJP 1.4<br /><a href="http://www.cise.ufl.edu/~sih" target="_blank" rel="nofollow">www.cise.ufl.edu/~sih</a>
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Swing HELP!