use of java.awt.Toolkit in project elki by elki-project.
the class GUIUtil method setLookAndFeel.
/**
* Setup look at feel.
*/
public static void setLookAndFeel() {
// If enabled, setup thread debugging.
if (THREAD_REPAINT_DEBUG) {
try {
Class<?> cls = ClassLoader.getSystemClassLoader().loadClass("org.jdesktop.swinghelper.debug.CheckThreadViolationRepaintManager");
RepaintManager.setCurrentManager((RepaintManager) cls.newInstance());
} catch (Exception e) {
// ignore
}
}
if (PREFER_GTK) {
try {
Toolkit toolkit = Toolkit.getDefaultToolkit();
// Note: we don't want to *require* these classes
// But if they exist, we're going to try using them.
Class<?> suntoolkit = Class.forName("sun.awt.SunToolkit");
Method testm = suntoolkit.getMethod("isNativeGTKAvailable");
if (suntoolkit.isInstance(toolkit) && (Boolean) testm.invoke(toolkit)) {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
return;
}
} catch (Exception e) {
// ignore
}
}
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
// ignore
}
}
use of java.awt.Toolkit in project azure-tools-for-java by Microsoft.
the class RedisPropertyView method copyToSystemClipboard.
private void copyToSystemClipboard(String key) {
StringSelection stringSelection = new StringSelection(key);
Toolkit toolKit = Toolkit.getDefaultToolkit();
if (toolKit == null) {
onError(COPY_FAIL);
return;
}
Clipboard clipboard = toolKit.getSystemClipboard();
clipboard.setContents(stringSelection, null);
}
use of java.awt.Toolkit in project azure-tools-for-java by Microsoft.
the class Utils method copyToSystemClipboard.
public static void copyToSystemClipboard(String key) throws Exception {
StringSelection stringSelection = new StringSelection(key);
Toolkit toolKit = Toolkit.getDefaultToolkit();
if (toolKit == null) {
throw new Exception("Cannot copy to system clipboard.");
}
Clipboard clipboard = toolKit.getSystemClipboard();
clipboard.setContents(stringSelection, null);
}
use of java.awt.Toolkit in project Fling by entertailion.
the class Fling method createAndShowGUI.
/**
* Create the main window frame
*/
public static void createAndShowGUI() {
Log.d(LOG_TAG, "set to system default LaF");
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ex) {
System.out.println("Cannot find system look and feel, setting to metal.");
}
Log.d(LOG_TAG, "createAndShowGUI");
flingFrame = new FlingFrame(appId);
// change the default app icon; might not work for all platforms
URL url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/logo.png");
Toolkit kit = Toolkit.getDefaultToolkit();
Image img = kit.createImage(url);
flingFrame.setIconImage(img);
flingFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
// flingFrame.setSize(420, 250);
// with scrubber
flingFrame.setSize(420, 275);
flingFrame.setLocationRelativeTo(null);
flingFrame.setVisible(true);
}
use of java.awt.Toolkit in project google-analytics-java by brsanthu.
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;
}
Aggregations