public void search() { btnSearch.setEnabled(false); String keyword = ""; keyword = txtKeyword.getText(); if (keyword != null && !keyword.isEmpty()) { keyword = keyword.trim(); } task = new CustomerSearchTask(keyword); task.addPropertyChangeListener(this); task.execute(); }
// End of variables declaration//GEN-END:variables @Override public void propertyChange(PropertyChangeEvent evt) { if ("progress".equals(evt.getPropertyName())) { int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); if (progress == 100) { try { customers = task.get(); populateTblCustomer(); } catch (InterruptedException | ExecutionException ex) { System.out.println("Exception:" + ex); } finally { btnSearch.setEnabled(true); } } } }