swing - Issue with SplashScreen java -
i need help code.
i'm having problem start splashscreen of java application. principal class (bolaojframe) extends jframe , calls screen logon extends jdialog. after validation of user, splashscreen created don't appears. doing wrong?
the splashscreen should appear after validation show jprogressbar while loading of class principal not finish.
this metodo main of pricipal class:
public static void main(string args[]) { /* set nimbus , sense */ //<editor-fold defaultstate="collapsed" desc=" , sense setting code (optional) "> /* if nimbus (introduced in java se 6) not available, remain default , feel. * details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ seek { (javax.swing.uimanager.lookandfeelinfo info : javax.swing.uimanager.getinstalledlookandfeels()) { if ("nimbus".equals(info.getname())) { javax.swing.uimanager.setlookandfeel(info.getclassname()); break; } } } grab (classnotfoundexception ex) { java.util.logging.logger.getlogger(bolaojframe.class.getname()).log(java.util.logging.level.severe, null, ex); } grab (instantiationexception ex) { java.util.logging.logger.getlogger(bolaojframe.class.getname()).log(java.util.logging.level.severe, null, ex); } grab (illegalaccessexception ex) { java.util.logging.logger.getlogger(bolaojframe.class.getname()).log(java.util.logging.level.severe, null, ex); } grab (javax.swing.unsupportedlookandfeelexception ex) { java.util.logging.logger.getlogger(bolaojframe.class.getname()).log(java.util.logging.level.severe, null, ex); } //</editor-fold> /* create , display form */ java.awt.eventqueue.invokelater(new runnable() { public void run() { bolaojframe principal= new bolaojframe(); principal.setlocationrelativeto(null); login = new loginjdialog(principal, true); if(newuser==true){ cardlayout cards = (cardlayout)(principal.jpprincipal.getlayout()); cards.show(principal.jpprincipal, "cadastro"); }else{ if(usuario.usercriado==0){ system.exit(0); }else{ splash telasplash =new splash(null); telasplash.setvisible(true); cardlayout cards = (cardlayout)(principal.jpprincipal.getlayout()); cards.show(principal.jpprincipal, "apostas"); principal.jlabel1.settext("bem vindo " + user.getusername()); principal.jlabel4.seticon(new util().dimencionaimagem(user.getfoto(),80)); horadosistema.start(principal.retomahora(),principal.lbrelagio); principal.montacards(); panelranking pr = new panelranking(10, 1, user.getusercod()); principal.jpranking.add(pr,"1"); if(pr.getposuser()>0){ principal.lbrankinginfo.settext("sua posição atual é " + pr.getposuser() + "º" ); } if(pr.getpontuacaouser()>0){ principal.lbpontuacaoinfo.settext("você fez " + pr.getpontuacaouser()+ " pontos" ); } principal.lbnext.requestfocus(); principal.verificadisponibilidad(); } } principal.setvisible(true); } }); } splashscreen class:
public splash(jframe owner) { //super(owner); setlayout(null); util.centralizarjanela(this, 521, 335); inicialize(); } public void inicialize(){ jlabel fundo = new jlabel(); //fundo.setlocation(new point(0,0)); fundo.seticon(new imageicon(getclass().getresource("/principal/splash.png"))); fundo.setsize(521, 315); add(fundo); barradeprogresso= new jprogressbar(); barradeprogresso.setbackground(color.red); barradeprogresso.setbounds(0, 315, 521, 20); barradeprogresso.setstringpainted(true); add(barradeprogresso); } public void setvalorbarradeprogresso(int progresso){ barradeprogresso.setvalue(progresso); } public int getvalorbarradeprogresso(){ homecoming barradeprogresso.getvalue(); }
my first guess setlayout(null);, sec guess you're not applying size or location splash window
normally, pack() , setlocationrelativeto(bolaojframe) want, because decided discard layout manager, pack no longer help you...
updated...
so basic workflow like...
bolaojframe principal= new bolaojframe(); principal.setlocationrelativeto(null); //... splash telasplash =new splash(null); telasplash.setvisible(true); //.. principal.setvisible(true); the problem this, windows appear (almost) simultaneously there no delay between setvisible commands.
you utilize javax.swing.timer insert short delay between making splash screen visible , principal
while not possible determine code snippet, it's possible blocking event dispatching thread, prevent new events processing , preventing windows been shown
java swing splash-screen splash
No comments:
Post a Comment