Вот программа (просто для примера):
import javax.swing.*;
import java.awt.event.*;
public class test {
public static void main(String args[]){
MainFrame m = new MainFrame();
m.setVisible(true);
}
}
class MainFrame extends JFrame implements WindowListener, ActionListener{
private JLabel leabl1 = new JLabel("TEST", JLabel.CENTER);
private JButton enter = new JButton("START");
public MainFrame(){
this.setSize(300,200);
this.addWindowListener(this);
JPanel p = new JPanel();
this.setContentPane(p);
p.setLayout(null);
leabl1.setBounds(0,20,300,20);
enter.setBounds(100,60,100,20);
p.add(leabl1);
p.add(enter);
enter.addActionListener(this);
}
public void windowClosing(WindowEvent e){System.exit(0);}
public void windowOpened(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void actionPerformed(ActionEvent e){
try {
leabl1.setText("TEST 1");
Thread.currentThread().sleep(5000);
leabl1.setText("TEST 2");
Thread.currentThread().sleep(5000);
leabl1.setText("TEST 3");
Thread.currentThread().sleep(5000);
leabl1.setText("TEST 4");
} catch (InterruptedException e2) {
e2.printStackTrace();
}
}
}
Вот эта часть:
leabl1.setText("TEST 1");
Thread.currentThread().sleep(5000);
leabl1.setText("TEST 2");
Thread.currentThread().sleep(5000);
leabl1.setText("TEST 3");
Thread.currentThread().sleep(5000);
leabl1.setText("TEST 4");