X-Received: by 10.236.24.195 with SMTP id x43mr11454245yhx.3.1382278281841; Sun, 20 Oct 2013 07:11:21 -0700 (PDT) X-Received: by 10.50.2.74 with SMTP id 10mr144750igs.15.1382278281669; Sun, 20 Oct 2013 07:11:21 -0700 (PDT) Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!news-xxxfer.readnews.com!209.85.216.87.MISMATCH!o2no15666596qas.0!news-out.google.com!9ni58915qaf.0!nntp.google.com!i2no23210086qav.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.gui Date: Sun, 20 Oct 2013 07:11:21 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=101.99.11.120; posting-account=4X4fnwoAAABZ1G_ecq8KuzoNFte5YhlC NNTP-Posting-Host: 101.99.11.120 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8f1ddeb0-aebc-435d-a8d9-f0fbe69d4e5f@googlegroups.com> Subject: How to add time delay in JFrame ? From: Khoa Bach Tran Injection-Date: Sun, 20 Oct 2013 14:11:21 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Received-Bytes: 2370 Xref: csiph.com comp.lang.java.gui:5383 First of all, sorry for my bad english. Now I have to demo how the sort code work on Java JFrame but the problem is I dont know how to make the delay between the switch. How can I add the delay when mark the column with color ? Already searched on many threads by googles but i'm too newbie to know how the code work with Swing timer. public void MarkColumn(JLabel column) { column.setBackground(new Color(255, 153, 0)); //Delay 1.5 seconds; } public void UnmarkColumn(JLabel column) { column.setBackground(new Color(51, 153, 255)); //Delay 1.5 seconds; } void sort() { for (int i = 0; i < list.size() - 1; i++) { MarkColumn(columns.get(i)); for (int j = list.size() - 1; j > i; j--) { MarkColumn(columns.get(j)); if (list.get(j).getPoint() < list.get(j - 1).getPoint()) { SinhVien tg = list.get(j - 1); list.set(j - 1, list.get(j)); list.set(j, tg); } UnmarkColumn(columns.get(j)); } UnmarkColumn(columns.get(i)); } } Very appreciated for your helps.