Search in sources :

Example 36 with Toolkit

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
    }
}
Also used : Toolkit(java.awt.Toolkit) Method(java.lang.reflect.Method)

Example 37 with Toolkit

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);
}
Also used : Toolkit(java.awt.Toolkit) Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 38 with Toolkit

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);
}
Also used : Toolkit(java.awt.Toolkit) Clipboard(java.awt.datatransfer.Clipboard) IOException(java.io.IOException) StringSelection(java.awt.datatransfer.StringSelection)

Example 39 with Toolkit

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);
}
Also used : Toolkit(java.awt.Toolkit) Image(java.awt.Image) URL(java.net.URL)

Example 40 with Toolkit

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;
}
Also used : GraphicsDevice(java.awt.GraphicsDevice) Toolkit(java.awt.Toolkit) Dimension(java.awt.Dimension) GraphicsEnvironment(java.awt.GraphicsEnvironment)

Aggregations

Toolkit (java.awt.Toolkit)93 Dimension (java.awt.Dimension)27 Point (java.awt.Point)20 Image (java.awt.Image)19 BufferedImage (java.awt.image.BufferedImage)14 URL (java.net.URL)14 GraphicsDevice (java.awt.GraphicsDevice)8 GraphicsEnvironment (java.awt.GraphicsEnvironment)7 Insets (java.awt.Insets)7 Rectangle (java.awt.Rectangle)6 IOException (java.io.IOException)6 Field (java.lang.reflect.Field)6 MediaTracker (java.awt.MediaTracker)5 ImageIcon (javax.swing.ImageIcon)5 Frame (java.awt.Frame)4 Clipboard (java.awt.datatransfer.Clipboard)4 Font (java.awt.Font)3 Graphics (java.awt.Graphics)3 GraphicsConfiguration (java.awt.GraphicsConfiguration)3 Method (java.lang.reflect.Method)3