Guest
Public paste!

Untitled

By: a guest | Mar 14th, 2010 | Syntax: Java | Size: 0.73 KB | Hits: 111 | Expires: Never
Copy text to clipboard
  1.                         dialog = new JDialog(frame);
  2.  
  3.                         SwingWorker<Void,Void> worker = new SwingWorker<Void,Void>(){
  4.                                
  5.                                 private Throwable theException = null;
  6.  
  7.                                 /* (non-Javadoc)
  8.                                  * @see javax.swing.SwingWorker#doInBackground()
  9.                                  */
  10.                                 @Override
  11.                                 protected Void doInBackground() {
  12.                                        
  13.                                         try{
  14.                                                
  15.                                                 // some work
  16.                                         }
  17.                                         catch(Throwable t){
  18.                                                
  19.                                                 theException = t;
  20.                                         }
  21.                                        
  22.                                         return null;
  23.                                        
  24.                                 }
  25.  
  26.                                 /* (non-Javadoc)
  27.                                  * @see javax.swing.SwingWorker#done()
  28.                                  */
  29.                                 @Override
  30.                                 protected void done() {
  31.                                        
  32.                                         dialogAvanzamento.setVisible(false);
  33.                                        
  34.                                         // other things
  35.                                        
  36.                                 }
  37.                                
  38.                         };
  39.                        
  40.  
  41.                        
  42.                         worker.execute();
  43.                        
  44.                         dialog.setVisible(true);