use of java.awt.Toolkit in project libgdx by libgdx.
the class LwjglAWTInput method showCursor.
private void showCursor(boolean visible) {
if (!visible) {
Toolkit t = Toolkit.getDefaultToolkit();
Image i = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
Cursor noCursor = t.createCustomCursor(i, new Point(0, 0), "none");
JFrame frame = findJFrame(canvas);
frame.setCursor(noCursor);
} else {
JFrame frame = findJFrame(canvas);
frame.setCursor(Cursor.getDefaultCursor());
}
}
use of java.awt.Toolkit in project h2o-2 by h2oai.
the class AwtRequestParameterDiscoverer method discoverParameters.
@Override
public DefaultRequest discoverParameters(GoogleAnalyticsConfig config, DefaultRequest request) {
super.discoverParameters(config, request);
Toolkit toolkit = Toolkit.getDefaultToolkit();
if (isEmpty(request.screenResolution())) {
Dimension screenSize = toolkit.getScreenSize();
request.screenResolution(((int) screenSize.getWidth()) + "x" + ((int) screenSize.getHeight()) + ", " + toolkit.getScreenResolution() + " dpi");
}
if (isEmpty(request.screenColors())) {
GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] graphicsDevices = graphicsEnvironment.getScreenDevices();
StringBuilder sb = new StringBuilder();
for (GraphicsDevice graphicsDevice : graphicsDevices) {
if (sb.length() != 0) {
sb.append(", ");
}
sb.append(graphicsDevice.getDisplayMode().getBitDepth());
}
request.screenColors(sb.toString());
}
return request;
}
use of java.awt.Toolkit in project processing by processing.
the class LinuxPlatform method initBase.
public void initBase(Base base) {
super.initBase(base);
String javaVendor = System.getProperty("java.vendor");
String javaVM = System.getProperty("java.vm.name");
if (javaVendor == null || (!javaVendor.contains("Sun") && !javaVendor.contains("Oracle")) || javaVM == null || !javaVM.contains("Java")) {
Messages.showWarning("Not fond of this Java VM", "Processing requires Java 8 from Oracle.\n" + "Other versions such as OpenJDK, IcedTea,\n" + "and GCJ are strongly discouraged. Among other things, you're\n" + "likely to run into problems with sketch window size and\n" + "placement. For more background, please read the wiki:\n" + "https://github.com/processing/processing/wiki/Supported-Platforms#linux", null);
}
// https://github.com/processing/processing/issues/2534
try {
Toolkit xToolkit = Toolkit.getDefaultToolkit();
java.lang.reflect.Field awtAppClassNameField = xToolkit.getClass().getDeclaredField("awtAppClassName");
awtAppClassNameField.setAccessible(true);
awtAppClassNameField.set(xToolkit, "Processing");
} catch (Exception e) {
// In case the implementation details change
e.printStackTrace();
}
}
use of java.awt.Toolkit in project jgnash by ccavanaugh.
the class StaticUIMethods method fixWindowManager.
static void fixWindowManager() {
Toolkit toolkit = Toolkit.getDefaultToolkit();
if (toolkit.getClass().getName().equals("sun.awt.X11.XToolkit")) {
// Oracle Bug #6528430 - provide proper app name on Linux
try {
Field awtAppClassNameField = toolkit.getClass().getDeclaredField("awtAppClassName");
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
awtAppClassNameField.setAccessible(true);
return null;
});
awtAppClassNameField.set(toolkit, Version.getAppName());
} catch (NoSuchFieldException | IllegalAccessException ex) {
Logger.getLogger(StaticUIMethods.class.getName()).log(Level.INFO, ex.getLocalizedMessage(), ex);
}
// Workaround for main menu, pop-up & mouse issues for Gnome 3 shell and Cinnamon
if ("gnome-shell".equals(System.getenv("DESKTOP_SESSION")) || "cinnamon".equals(System.getenv("DESKTOP_SESSION")) || "gnome".equals(System.getenv("DESKTOP_SESSION")) || (System.getenv("XDG_CURRENT_DESKTOP") != null && System.getenv("XDG_CURRENT_DESKTOP").contains("GNOME"))) {
try {
Class<?> x11_wm = Class.forName("sun.awt.X11.XWM");
Field awt_wMgr = x11_wm.getDeclaredField("awt_wmgr");
awt_wMgr.setAccessible(true);
Field other_wm = x11_wm.getDeclaredField("OTHER_WM");
other_wm.setAccessible(true);
if (awt_wMgr.get(null).equals(other_wm.get(null))) {
Field metaCity_Wm = x11_wm.getDeclaredField("METACITY_WM");
metaCity_Wm.setAccessible(true);
awt_wMgr.set(null, metaCity_Wm.get(null));
Logger.getLogger(StaticUIMethods.class.getName()).info("Installed window manager workaround");
}
} catch (ClassNotFoundException | NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
Logger.getLogger(StaticUIMethods.class.getName()).log(Level.INFO, ex.getLocalizedMessage(), ex);
}
}
}
}
use of java.awt.Toolkit in project jgnash by ccavanaugh.
the class CursorUtils method getCursor.
/**
* Returns a custom cursor object of the type specified.
*
* @param type the type of the custom cursor as defined in this class
* @return the specified custom cursor
* @throws IllegalArgumentException if the specified cursor type is
* invalid
*/
public static Cursor getCursor(int type) {
if (type < ZOOM_IN || type > ZOOM_OUT) {
throw new IllegalArgumentException("illegal cursor type");
}
if (predefined[type] == null) {
try {
// See comment above the static variable.
final Object[] props = cursorProperties[type];
final String name = (String) props[0];
final String resource = (String) props[1];
final int[] spot = (int[]) props[2];
final Point point = new Point(spot[0], spot[1]);
final Toolkit tk = Toolkit.getDefaultToolkit();
Image image = IconUtils.getImage(resource);
predefined[type] = tk.createCustomCursor(image, point, name);
} catch (IndexOutOfBoundsException | HeadlessException e) {
// this would be an error in the properties
predefined[type] = Cursor.getDefaultCursor();
throw new RuntimeException(e);
}
}
return predefined[type];
}
Aggregations