Search in sources :

Example 71 with Toolkit

use of java.awt.Toolkit in project cytoscape-impl by cytoscape.

the class CytoscapeDesktop method setLocationOfFloatingFrame.

private void setLocationOfFloatingFrame(JFrame frame, CytoPanelImpl cytoPanel) {
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenDimension = tk.getScreenSize();
    // Get Absolute Location and Bounds, relative to Screen
    Rectangle bounds = getBounds();
    bounds.setLocation(getLocationOnScreen());
    Point p = CytoPanelUtil.getLocationOfExternalWindow(screenDimension, bounds, frame.getSize(), cytoPanel.getCytoPanelName(), false);
    frame.setLocation(p);
    frame.setVisible(true);
}
Also used : Rectangle(java.awt.Rectangle) Toolkit(java.awt.Toolkit) Dimension(java.awt.Dimension) Point(java.awt.Point)

Example 72 with Toolkit

use of java.awt.Toolkit in project elki by elki-project.

the class TreePopup method computePopupBounds.

protected Rectangle computePopupBounds(Component parent, int px, int py, int pw, int ph) {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Rectangle screenBounds;
    // Calculate the desktop dimensions relative to the combo box.
    GraphicsConfiguration gc = parent.getGraphicsConfiguration();
    Point p = new Point();
    SwingUtilities.convertPointFromScreen(p, parent);
    if (gc != null) {
        Insets screenInsets = toolkit.getScreenInsets(gc);
        screenBounds = gc.getBounds();
        screenBounds.width -= (screenInsets.left + screenInsets.right);
        screenBounds.height -= (screenInsets.top + screenInsets.bottom);
        screenBounds.x += (p.x + screenInsets.left);
        screenBounds.y += (p.y + screenInsets.top);
    } else {
        screenBounds = new Rectangle(p, toolkit.getScreenSize());
    }
    Rectangle rect = new Rectangle(px, py, pw, ph);
    if (py + ph > screenBounds.y + screenBounds.height && ph < screenBounds.height) {
        rect.y = -rect.height;
    }
    return rect;
}
Also used : Insets(java.awt.Insets) Rectangle(java.awt.Rectangle) Toolkit(java.awt.Toolkit) Point(java.awt.Point) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 73 with Toolkit

use of java.awt.Toolkit in project pivot by apache.

the class Platform method getCursorBlinkRate.

/**
 * @return The system cursor blink rate.
 */
public static int getCursorBlinkRate() {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Integer cursorBlinkRate = (Integer) toolkit.getDesktopProperty("awt.cursorBlinkRate");
    if (cursorBlinkRate == null) {
        cursorBlinkRate = Integer.valueOf(DEFAULT_CURSOR_BLINK_RATE);
    }
    return cursorBlinkRate.intValue();
}
Also used : Toolkit(java.awt.Toolkit)

Example 74 with Toolkit

use of java.awt.Toolkit in project com.revolsys.open by revolsys.

the class ClipboardUtil method getClipboard.

public static Clipboard getClipboard() {
    final Toolkit toolkit = Toolkit.getDefaultToolkit();
    final Clipboard clipboard = toolkit.getSystemClipboard();
    return clipboard;
}
Also used : Toolkit(java.awt.Toolkit) Clipboard(java.awt.datatransfer.Clipboard)

Example 75 with Toolkit

use of java.awt.Toolkit in project beast2 by CompEvol.

the class Utils6 method startSplashScreen.

/*
        This could live in the desktop script.
        However we'd like to get it on the screen as quickly as possible.
    */
public static void startSplashScreen() {
    Image img = getIcon("beast/app/draw/icons/beauti.png").getImage();
    int width = 2 * img.getWidth(null), height = img.getHeight(null);
    Window win = new Window(new Frame());
    win.pack();
    can = new Canvas();
    // why is this necessary?
    can.setSize(width, height);
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension dim = tk.getScreenSize();
    win.setBounds(dim.width / 2 - width / 2, dim.height / 2 - height / 2, width, height);
    win.add("Center", can);
    // Image img=tk.getImage(
    // Utils.class.getResource("beast.png") ); //what
    MediaTracker mt = new MediaTracker(can);
    mt.addImage(img, 0);
    try {
        mt.waitForAll();
    } catch (Exception e) {
    }
    Graphics gr = can.getBufferedGraphics();
    gr.drawImage(img, width / 4, 0, can);
    win.setVisible(true);
    win.toFront();
    splashScreen = win;
}
Also used : Window(java.awt.Window) Graphics(java.awt.Graphics) Frame(java.awt.Frame) MediaTracker(java.awt.MediaTracker) Toolkit(java.awt.Toolkit) Dimension(java.awt.Dimension) Image(java.awt.Image) IOException(java.io.IOException)

Aggregations

Toolkit (java.awt.Toolkit)95 Dimension (java.awt.Dimension)29 Point (java.awt.Point)21 Image (java.awt.Image)19 BufferedImage (java.awt.image.BufferedImage)14 URL (java.net.URL)14 GraphicsDevice (java.awt.GraphicsDevice)8 Insets (java.awt.Insets)8 GraphicsEnvironment (java.awt.GraphicsEnvironment)7 Rectangle (java.awt.Rectangle)7 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 BorderLayout (java.awt.BorderLayout)3 Font (java.awt.Font)3 Graphics (java.awt.Graphics)3 GraphicsConfiguration (java.awt.GraphicsConfiguration)3