public lyridisplay (java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();//to create a JList
/* folowing code inside try preforms DB operations*/
/*It will return array of string s*/
try {
s = insert.select();
} catch (ClassNotFoundException ex) {
Logger.getLogger(lyridisplay.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(lyridisplay.class.getName()).log(Level.SEVERE, null, ex);
}
//now set the string s to JList
jList1.setModel(new javax.swing.AbstractListModel() {
String[] strings =s;
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
}
I think the above code should block the EDT
, because of the DB operations before setting up JList
and it runs on EDT
.But It dosn't.The program runs smooth.I did similar thing before,resulting to blocked EDT
and a frozen program.I preformed that code in a separate thread,as adviced by SO users.Why this code dosn't block EDT
?