boa tarde !!!
tenho uma tela de SplashScreen no meu projeto e gostaria de saber como chamar a tela principal apos o splash ?
o frame da tela principal e:
Janela menu = new Janela();
menu.setVisible(true);
package visao;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
public class ExemploSplashBarraProgresso extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JLabel lblSplash = null;
private JProgressBar prbProgresso = null;
private Timer timer = null;
public ExemploSplashBarraProgresso() {
super();
initialize();
setLocationRelativeTo(null);
}
private void initialize() {
this.setSize(600, 450);
this.setContentPane(getJContentPane());
this.setTitle("CARREGANDO...");
// Vou mostrar 100 passos (cada passo deve durar 4000 / 100 = 40 ms então)
// No último passo, só para facilitar, vou fechar esta janela, você pode fazer
// outra coisa.
timer = new Timer(40, new ActionListener() {
private int step = 0;
@Override
public void actionPerformed(ActionEvent e) {
step++;
prbProgresso.setValue(step);
if (step == 100) {
ExemploSplashBarraProgresso.this.dispose();
}
}
});
timer.start();
}
private JPanel getJContentPane() {
if (jContentPane == null) {
lblSplash = new JLabel();
lblSplash.setIcon(new javax.swing.ImageIcon("E:/pendrive/LP2/Locadora/src/projeto/icones/java1.jpg"));
lblSplash.setHorizontalAlignment(SwingConstants.CENTER);
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.add(lblSplash, BorderLayout.CENTER);
jContentPane.add(getPrbProgresso(), BorderLayout.SOUTH);
}
return jContentPane;
}
private JProgressBar getPrbProgresso() {
if (prbProgresso == null) {
prbProgresso = new JProgressBar();
}
return prbProgresso;
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ExemploSplashBarraProgresso thisClass = new ExemploSplashBarraProgresso();
thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
thisClass.setVisible(true);
}
});
}
}