diff --git a/src/dorkbox/systemTray/swt/Swt$1.class b/src/dorkbox/systemTray/swt/Swt$1.class new file mode 100644 index 0000000..37c4a45 Binary files /dev/null and b/src/dorkbox/systemTray/swt/Swt$1.class differ diff --git a/src/dorkbox/systemTray/swt/Swt.class b/src/dorkbox/systemTray/swt/Swt.class new file mode 100644 index 0000000..5ee586e Binary files /dev/null and b/src/dorkbox/systemTray/swt/Swt.class differ diff --git a/src/dorkbox/systemTray/swt/Swt.java b/src/dorkbox/systemTray/swt/Swt.java new file mode 100644 index 0000000..3046358 --- /dev/null +++ b/src/dorkbox/systemTray/swt/Swt.java @@ -0,0 +1,38 @@ +/* + * Copyright 2016 dorkbox, llc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package dorkbox.systemTray.swt; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; + +/** + * This isn't possible with reflection - so we compile it AHEAD of time and save the bytecode (which is then included with the release) + */ +public +class Swt { + public static + void onShutdown(final Runnable runnable) { + Display.getCurrent().getShells()[0].addListener(SWT.Close, new Listener() { + @Override + public + void handleEvent(final Event event) { + runnable.run(); + } + }); + } +}