ChangingJtextfield border color
Hello folks!!I'm trying to change the color with this method when a textfield is filled wrong:
publicvoid setErrorColor (final JComponent comp){
SwingUtilities.invokeLater(new Runnable(){
publicvoid run(){
comp.requestFocus();
comp.setBorder(new LineBorder(Color.RED) );
}
});
However, i have programmed all the textfields to change the border color when it is focusgained (to color blue). And the method above is to set the color when a field is filled wrong and to get the focus.It doesn't work!
[919 byte] By [
MrSmyllea] at [2007-11-27 10:31:38]

# 1
> It doesn't work!
Then something else in your program is wrong!
If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)",
see http://homepage1.nifty.com/algafield/sscce.html,
that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
Don't forget to use the "Code Formatting Tags",
see http://forum.java.sun.com/help.jspa?sec=formatting,
so the posted code retains its original formatting.
# 3
comp.removeFocusListener(...);
comp.requestFocus();
comp.setBorder( new LineBorder(Color.RED) );
comp.addFocusListener(...);