Skip to content

Instantly share code, notes, and snippets.

@oddbjornkvalsund
Created February 18, 2015 15:47
Show Gist options
  • Save oddbjornkvalsund/bae8f060be504d6f5334 to your computer and use it in GitHub Desktop.
Save oddbjornkvalsund/bae8f060be504d6f5334 to your computer and use it in GitHub Desktop.
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