/**
* @param args the command line arguments
*/
public static void main(String args[]) throws Exception {
Thread.currentThread().setUncaughtExceptionHandler(new SwingExceptionHandler());
Toolkit.getDefaultToolkit().getSystemEventQueue().push(new EventRateCounter());
//System.setProperty("socksProxyHost", "localhost");
//System.setProperty("socksProxyPort", "9050");
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
Model.getTaskSaver().saveList();
System.out.println("saved tasks");
} catch (Exception ex) {
System.out.println("could not save tasks");
ex.printStackTrace();
}
try {
Model.getDownloadSaver().saveAllDownloads();
System.out.println("saved downloads");
} catch (Exception ex) {
System.out.println("could not save downloads");
ex.printStackTrace();
}
try {
JavaDBDataSource.getInstance().shutdownDB();
System.out.println("shutdownDB()");
} catch (Exception ex) {
System.out.println("shutdownDB() exception is normal");
System.out.println(ex);
}
}
});
Model.build();
View.build();
Control.build();
Model.loadData();
View.initViewState();
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
Thread.currentThread().setUncaughtExceptionHandler(new SwingExceptionHandler());
}
});
} catch (InterruptedException ex) {
Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex);