import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
-import java.awt.desktop.AboutEvent;
+import java.awt.desktop.QuitStrategy;
+/* not importing directly. Calling classes with full name in try block to allow Java 1.8 runtime
import java.awt.desktop.AboutHandler;
import java.awt.desktop.PreferencesEvent;
import java.awt.desktop.PreferencesHandler;
import java.awt.desktop.QuitHandler;
import java.awt.desktop.QuitResponse;
import java.awt.desktop.QuitStrategy;
+*/
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
try
{
+ Float specversion = Float.parseFloat(
+ System.getProperty("java.specification.version"));
- if (Platform.isAMac())
+ if (specversion >= 9)
{
- if (desktopClass.getDeclaredMethod("setAboutHandler",
- new Class[]
- { AboutHandler.class }) != null)
+ if (Platform.isAMac())
{
-
- hdesktop.setAboutHandler(new AboutHandler()
+ if (desktopClass.getDeclaredMethod("setAboutHandler",
+ new Class[]
+ { java.awt.desktop.AboutHandler.class }) != null)
{
- @Override
- public void handleAbout(AboutEvent e)
- {
- aboutMenuItem_actionPerformed(null);
- }
- });
- }
+ hdesktop.setAboutHandler(new java.awt.desktop.AboutHandler()
+ {
+ @Override
+ public void handleAbout(java.awt.desktop.AboutEvent e)
+ {
+ aboutMenuItem_actionPerformed(null);
+ }
+ });
- if (desktopClass.getDeclaredMethod("setPreferencesHandler",
- new Class[]
- { PreferencesHandler.class }) != null)
- {
+ }
- hdesktop.setPreferencesHandler(new PreferencesHandler()
+ if (desktopClass.getDeclaredMethod("setPreferencesHandler",
+ new Class[]
+ { java.awt.desktop.PreferencesHandler.class }) != null)
{
- @Override
- public void handlePreferences(PreferencesEvent e)
- {
- preferences_actionPerformed(null);
- }
- });
- }
+ hdesktop.setPreferencesHandler(
+ new java.awt.desktop.PreferencesHandler()
+ {
+ @Override
+ public void handlePreferences(
+ java.awt.desktop.PreferencesEvent e)
+ {
+ preferences_actionPerformed(null);
+ }
+ });
- if (desktopClass.getDeclaredMethod("setQuitHandler",
- new Class[]
- { QuitHandler.class }) != null)
- {
+ }
- hdesktop.setQuitHandler(new QuitHandler()
+ if (desktopClass.getDeclaredMethod("setQuitHandler",
+ new Class[]
+ { java.awt.desktop.QuitHandler.class }) != null)
{
- @Override
- public void handleQuitRequestWith(QuitEvent e, QuitResponse r)
+
+ hdesktop.setQuitHandler(new java.awt.desktop.QuitHandler()
{
- boolean confirmQuit = jalview.bin.Cache
- .getDefault(CONFIRM_KEYBOARD_QUIT, true);
- int n;
- if (confirmQuit)
+ @Override
+ public void handleQuitRequestWith(
+ java.awt.desktop.QuitEvent e,
+ java.awt.desktop.QuitResponse r)
{
- n = JOptionPane.showConfirmDialog(null,
- MessageManager.getString("label.quit_jalview"),
- MessageManager.getString("action.quit"),
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.PLAIN_MESSAGE, null);
- }
- else
- {
- n = JOptionPane.OK_OPTION;
- }
- if (n == JOptionPane.OK_OPTION)
- {
- System.out.println("Shortcut Quit confirmed by user");
- quit();
- r.performQuit(); // probably won't reach this line, but just
- // in
- // case
- }
- else
- {
- r.cancelQuit();
- System.out.println("Shortcut Quit cancelled by user");
+ boolean confirmQuit = jalview.bin.Cache
+ .getDefault(CONFIRM_KEYBOARD_QUIT, true);
+ int n;
+ if (confirmQuit)
+ {
+ n = JOptionPane.showConfirmDialog(null,
+ MessageManager.getString("label.quit_jalview"),
+ MessageManager.getString("action.quit"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.PLAIN_MESSAGE, null);
+ }
+ else
+ {
+ n = JOptionPane.OK_OPTION;
+ }
+ if (n == JOptionPane.OK_OPTION)
+ {
+ System.out.println("Shortcut Quit confirmed by user");
+ quit();
+ r.performQuit(); // probably won't reach this line, but just
+ // in
+ // case
+ }
+ else
+ {
+ r.cancelQuit();
+ System.out.println("Shortcut Quit cancelled by user");
+ }
}
- }
- });
- hdesktop.setQuitStrategy(QuitStrategy.CLOSE_ALL_WINDOWS);
+ });
+ hdesktop.setQuitStrategy(QuitStrategy.CLOSE_ALL_WINDOWS);
+ }
}
}
+ else
+ {
+ System.out.println(
+ "Not going to try setting APQ Handlers as java.spec.version is "
+ + specversion);
+ }
- } catch (NoSuchMethodException e)
+ } catch (Exception e)
{
System.out.println(
- "NoSuchMethodException when looking for About, Preferences, Quit Handlers");
+ "Exception when looking for About, Preferences, Quit Handlers");
e.printStackTrace();
+ } catch (Throwable t)
+ {
+ System.out.println(
+ "Throwable when looking for About, Preferences, Quit Handlers");
+ t.printStackTrace();
}
setAPQHandlers = true;