Im making a game in jframe and i dont know how to use applet and making a inner class so i stayed with jframe style. and this is my problem. how can i add delay between components in jframe.
i added a "loading.gif" in the center of the frame. and a jbutton "continue" in the south part of the frame but i want to add delay for 3 seconds before the "continue button" appears and the "loading.gif" disappear. (like in a loading part of the games).
and this is my code...
//the p2 components
ImageIcon loading = new ImageIcon("C:\\java pics\\loading.gif");
JLabel startLoading = new JLabel(loading);
JButton continue1 = new JButton("Continue");
p2.add(startLoading,borderlayout.center);
p2.add(continue1,borderlayout.south);
//the jbutton continue event
start.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
f.add(p2);
f.remove(p1);
f.setVisible(true);
f.revalidate();
f.repaint();
Timer t = new Timer();
//delay for 3 seconds
try {
Timer.delay(3000);
} catch (InterruptedException ee) {
return;
}
t.start();
}
});
I will appreciate any help.