Exemplo n.º 1
0
 /**
  * Register for special events available on the Mac, such as showing the about screen, showing the
  * preferences or double-clicking a file.
  *
  * @throws RuntimeException if the adapter methods could not be loaded.
  */
 private void registerForMacOSXEvents() throws RuntimeException {
   if (!Platform.onMac()) return;
   try {
     // Generate and register the OSXAdapter, passing it a hash of all the methods we wish to
     // use as delegates for various com.apple.eawt.ApplicationListener methods
     OSXAdapter.setQuitHandler(this, getClass().getDeclaredMethod("quit", (Class[]) null));
     OSXAdapter.setAboutHandler(this, getClass().getDeclaredMethod("showAbout", (Class[]) null));
     OSXAdapter.setPreferencesHandler(
         this, getClass().getDeclaredMethod("showPreferences", (Class[]) null));
     OSXAdapter.setFileHandler(this, getClass().getDeclaredMethod("readFromFile", String.class));
   } catch (Exception e) {
     throw new RuntimeException("Error while loading the OS X Adapter.", e);
   }
   // On the Mac, if all windows are closed the menu bar will be empty.
   // To solve this, we create an off-screen window with the same menu bar as visible windows.
   hiddenFrame = new JFrame();
   hiddenFrame.setJMenuBar(new NodeBoxMenuBar());
   hiddenFrame.setUndecorated(true);
   hiddenFrame.setSize(0, 0);
   hiddenFrame.setLocation(-100, -100);
   hiddenFrame.pack();
   hiddenFrame.setVisible(true);
 }
Exemplo n.º 2
0
 /**
  * Creates the necessary directories used for storing user scripts and Python libraries.
  *
  * @throws RuntimeException if we can't create the user directories. This is fatal.
  */
 private void createNodeBoxDataDirectories() throws RuntimeException {
   Platform.getUserDataDirectory().mkdir();
   Platform.getUserScriptsDirectory().mkdir();
   Platform.getUserPythonDirectory().mkdir();
 }