boa tarde, tenho um splash simples que simula ja jprogressbar carregando por uns 5 segundos…
segue essa splash abaixo:
[code]package grafica;
import db.ConexaoDB;
import java.awt.Dimension;
import java.net.ServerSocket;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JProgressBar;
import javax.swing.JWindow;
import org.netbeans.lib.awtextra.AbsoluteConstraints;
import org.netbeans.lib.awtextra.AbsoluteLayout;
public class Splash extends JWindow{
private static ServerSocket s;
AbsoluteLayout Absoluto;
AbsoluteConstraints absimage, AbsBarra,AbsLabel,AbsDate;
ImageIcon image;
JLabel jlabel,jLabel1,jLabelDate;
JProgressBar barra;
Integer value;
Float versao;
Date dataupdate;
ConexaoDB obj_conexao = new ConexaoDB();
public Splash(){
try { // aki nao permite que se abra mais de uma instancia do software por vez nesta maquina
s = new ServerSocket(9581);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, “Desculpe, mas só uma aplicação pode ser executada por vez.”);
System.exit(0);
}
obj_conexao.conecta(); // conecta o db
Autent();
SelectVersao();
Absoluto = new AbsoluteLayout();
absimage = new AbsoluteConstraints(0, 0);
AbsBarra = new AbsoluteConstraints(14,9);
AbsLabel = new AbsoluteConstraints(300,40);
AbsDate = new AbsoluteConstraints(300,60);
jLabel1 = new JLabel();
jlabel = new JLabel();
jLabelDate = new JLabel();
barra = new JProgressBar();
barra.setPreferredSize(new Dimension(200,15));
this.getContentPane().setLayout(Absoluto);
image = new ImageIcon(this.getClass().getResource(“logoGesObras2.png”));
jlabel.setIcon(image);
jLabel1.setText(“Versão: “+versao);
jLabelDate.setText(””+new SimpleDateFormat(“dd/MM/yyyy”).format(dataupdate));
this.getContentPane().add(jLabel1,AbsLabel);
this.getContentPane().add(jLabelDate,AbsDate);
this.getContentPane().add(jlabel,absimage);
this.getContentPane().add(barra,AbsBarra);
new Thread(){
public void run(){
//lookandfeel para mudar a aparencia do programa
try {
javax.swing.UIManager.setLookAndFeel("com.jtattoo.plaf.mcwin.McWinLookAndFeel");
} catch (Exception ex) {
//
}
int i=0;
while(i<101){
barra.setValue(i);
i++;
try{
sleep(50);
} catch (InterruptedException ex){
Logger.getLogger(Splash.class.getName()).log(Level.SEVERE, null, ex);
}
}
//System.exit(0);
if(value == 1){
new Autenticacao("PADRAO").setVisible(true);
}else{
new Autenticacao(null).setVisible(true);
}
Splash.this.dispose();
}
}.start();
this.pack();
this.setVisible(true);
this.setLocationRelativeTo(null);
}
public static void main(String args[]){
new Splash();
}
private void Autent(){
obj_conexao.executeSQL("SELECT CI.AUTE"
+" FROM CONFIGURACOES_INTERNAS CI");
try {
while (obj_conexao.resultset.next()) {
value = obj_conexao.resultset.getInt("AUTE"); //codigo na 0
}
} catch (SQLException ex) {
Logger.getLogger(NovoServico.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void SelectVersao(){
obj_conexao.executeSQL("SELECT * FROM VERSAO ORDER BY DATA DESC ROWS 1");
try {
while (obj_conexao.resultset.next()) {
versao = obj_conexao.resultset.getFloat("VERSAO");
dataupdate = obj_conexao.resultset.getDate("DATA");
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null,ex);
}
}
}[/code]
como pode-se ver além de mostrar a splash tbm carrega a versao do sistema e após chama o jprincipal do sistema.
mas gostaria que mostrasse de verdade o que está carregando na memória como no splash do NetBeans, e após esse carregando ai sim chamasse o jprincipal.
se alguém tiver alguma idéia me dê uma ajuda!
valeu