Class SingleAppHandler

java.lang.Object
net.mcreator.util.SingleAppHandler
All Implemented Interfaces:
Closeable, AutoCloseable

public class SingleAppHandler extends Object implements Closeable
  • Constructor Details

    • SingleAppHandler

      public SingleAppHandler(List<String> args, Consumer<List<String>> secondaryAppLaunchedHandler)
      Parameters:
      args - Command line args of this instance
      secondaryAppLaunchedHandler - Called in the first instance when a secondary instance sends its args
  • Method Details

    • tryAcquireLock

      public boolean tryAcquireLock()
      Tries to acquire the single-instance lock. If another instance is running, sends args to the first instance.
      Returns:
      true if this is the first instance (or if locking completely fails), false if another instance is already running
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • bringToFront

      public static void bringToFront(JFrame frame)