Я пытаюсь отключить флажок перед сном, но после нажатия кнопки флажок не отключается перед сном. Если вы спите, флажок будет отключен. Как сначала отключить флажок?
public class Class implements ActionListener {
private JCheckBox checkbox;
private JButton button;
public void method() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(235, 168);
checkbox = new JCheckBox("checkbox");
frame.getContentPane().add(checkbox, BorderLayout.WEST);
button = new JButton("button");
frame.getContentPane().add(button, BorderLayout.CENTER);
button.addActionListener(this);
frame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
checkbox.setEnabled(false);
try {
Thread.sleep(5000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}