jeudi 13 mars 2014

Reading data from db and showing progress indicator at the same time


Vote count:

0




I need help with showing progress indicator while reading the data from the database. An example that I have done is interrupted in the middle of a new thread and continues to run a main thread. When the main thread is carried out until the end, then the execution of another thread continues. What is missing in this?



private void loadingData() throws InterruptedException{

prgIndLogin.setVisible(true);
prgIndLogin.setProgress(-1);

Thread newThrd = new Thread(new Runnable() {
@Override
public void run() {


try {
KorisnikJpaController korCont = new KorisnikJpaController(Persistence.createEntityManagerFactory("LawOfficeV2PU"));
EntityManager em = korCont.getEntityManager();

logedUser = (Korisnik) em.createNamedQuery("Korisnik.findByUsernameAndPassword")
.setParameter("usernamekor", tbxUsername.getText())
.setParameter("passwordkor", passField.getText())
.getSingleResult();

em.close();
status=true;
} catch(Exception e) {
status = false;
e.printStackTrace();
} finally {
Platform.runLater(new Runnable() {
@Override
public void run() {
prgIndLogin.setVisible(false);
}
});
}
}
});
newThrd.start();

}


asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire