I have a Dialog window with a Button ko
and a JLabel l
. The button`s label refreshes at 1000ms from 5 to 1. There are 2 problems: the JLabel l
it`s not displayed before the counter starts, it`s displayed after that, and the button doesn`t work during the countdown, if i push it during the countdown the window closes(thats the function if the ko
button) but only after the countdown finishes. This is the piece of code:
public AskWindow(Frame parinte, boolean modala){
super(parinte, modala);
JLabel l;
int t = 5;
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
MyMain.raspuns = null;
dispose();
}
});
Panel panel = new Panel();
ko = new Button("OK");
l = new JLabel();
l.setText("ati castigat de "+ nrJocT + " ori");
panel.add(l);
panel.add(ko);
add(panel, BorderLayout.SOUTH);
setLocationRelativeTo(parinte);
pack();
ko.addActionListener(this);
setVisible(true);
for (int i=0; i < t; i++)
{
ko.setLabel("" + (t-i));
try{
Thread.sleep(1000);
}
catch(InterruptedException o){}
}
}