java - How can i change jtextfield border after 5 seconds? -


i try change jtextfield border after 5 seconds. doesnt work. code:

    // here vaildate field , set border red     if (applicationnamefield.gettext().equals("")) {         border newborder = borderfactory.createlineborder(color.red, 1);         applicationnamefield.setborder(newborder);         errorcode.settext("error field cant empty");     }     if (applicationhostfield.gettext().equals("")) {         border newborder = borderfactory.createlineborder(color.red, 1);         applicationhostfield.setborder(newborder);         errorcode.settext("error field cant empty");     }     // here change border start normal color (color black)    try {         timeunit.seconds.sleep(5);         border newborder = borderfactory.createlineborder(color.black, 1);         applicationnamefield.setborder(newborder);         border newborder2 = borderfactory.createlineborder(color.black, 1);         applicationhostfield.setborder(newborder2);      } catch (interruptedexception ex) {         system.out.print(ex.getmessage());     } 

after code jtextfields borders black , not colored red color.

also tried with:

     thread.sleep(5000); 

but effect same. help?

you need use javax.swing.timer trigger desired action after 5 seconds. thread.wait (or other kind of waiting) doesn't work expected because nothing drawn until thread returns main event loop.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -