Created
February 18, 2015 15:47
-
-
Save oddbjornkvalsund/bae8f060be504d6f5334 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.sun.glass.ui.PlatformFactory; | |
import com.sun.glass.ui.monocle.MonoclePlatformFactory; | |
import com.sun.glass.ui.monocle.NativePlatformFactory; | |
import com.sun.glass.ui.monocle.headless.HeadlessPlatform; | |
import javafx.application.Application; | |
import java.lang.reflect.Field; | |
public class MonocleRunner { | |
public static void main(String[] args) { | |
assignPrivateStaticField(PlatformFactory.class, "instance", new MonoclePlatformFactory()); | |
assignPrivateStaticField(NativePlatformFactory.class, "platform", new HeadlessPlatform()); | |
Application.launch(MonocleApplication.class, args); | |
} | |
private static void assignPrivateStaticField(Class<?> cls, String name, Object value) { | |
try { | |
Field field = cls.getDeclaredField(name); | |
field.setAccessible(true); | |
field.set(cls, value); | |
field.setAccessible(false); | |
} catch (Exception e) { | |
throw new RuntimeException(e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment