ok.
quindi in sostanza è che questo quello che dovrei fare giusto?
codice:
public class LoadingDialog extends SwingWorker<Object, Object> {
private JDialog jd;
private Service jsb;
public LoadingDialog(JFrame frame) {
jsb = new Service();
jd = new JDialog(frame, true);
jd.add(BorderLayout.CENTER, new JLabel("...LOADING..."));
jd.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
jd.setSize(300, 75);
jd.setResizable(false);
jd.setLocationRelativeTo(frame);
}
@Override
protected Object doInBackground() throws Exception {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
jd.setVisible(true);
// OPERAZIONI
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
}
}
});
Thread.sleep(4000);
return null;
}
@Override
protected void done() {
jd.setVisible(false);
}
}
così mi sembra che funzioni già meglio.
nel jframe invece faccio solo richiamo al worker:
codice:
LoadingDialog ld = new LoadingDialog(this);
ld.execute();