How to add time delay in JFrame ?
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.