summaryrefslogtreecommitdiff
path: root/demos/java/gsviewer/src/com/artifex/gsviewer/Main.java
blob: beecdd3b0ee4519ce9589320889c2ea3283240c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.artifex.gsviewer;

import java.io.IOException;

import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import com.artifex.gsviewer.gui.ViewerWindow;

public class Main {

	public static void main(String[] args) {
		Runtime.getRuntime().addShutdownHook(new Thread(new Shutdown()));

		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
				| UnsupportedLookAndFeelException e) {
			System.err.println("Failed to set Look and Feel: " + e);
		}

		ViewerWindow win = new ViewerWindow(new ViewerController());
		SwingUtilities.invokeLater(() -> {
			win.setVisible(true);
		});
	}

	private static class Shutdown implements Runnable {

		@Override
		public void run() {
			try {
				Settings.SETTINGS.save();
			} catch (IOException e) {
				System.err.println("Failed to write settings file");
				e.printStackTrace();
			}
		}

	}
}