Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Flashing a JTextField background color

843805Feb 4 2007 — edited Feb 4 2007
Hi folks. I have the following lines of code:
query.setBackground(Color.RED);
     
                try
                {
                    Thread.sleep(1000);
                }
                catch(InterruptedException e)
                {
                    System.out.println(e);
                }
                
query.setBackground(Color.WHITE);
the object query is a JTextField. I want to be able to get the background of query to flash red for one second then revert back to white background. I have tried using javax.swing.Timer to do this, and have even tried using an actual thread class as opposed to above but none of these options have worked. Instead my GUI locks for the whole second and I still have a white background in the text field.

Hope someone knows the answer to this! I want to get to bed before 4am... currently 330am... ugghhh.... lol
Jason.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 4 2007
Added on Feb 4 2007
3 comments
730 views