Example usage for java.awt Toolkit getDefaultToolkit

List of usage examples for java.awt Toolkit getDefaultToolkit

Introduction

In this page you can find the example usage for java.awt Toolkit getDefaultToolkit.

Prototype

public static synchronized Toolkit getDefaultToolkit() 

Source Link

Document

Gets the default toolkit.

Usage

From source file:MainClass.java

public static void main(String[] args) {
    Toolkit tk = Toolkit.getDefaultToolkit();
    System.out.println("Menu shortcut key mask = " + tk.getMenuShortcutKeyMask());

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

    JFrame window = new JFrame();
    window.setSize(300, 300);/*from   www.j  av  a2 s.c  om*/

    int w = window.getSize().width;
    int h = window.getSize().height;
    int x = (dim.width - w) / 2;
    int y = (dim.height - h) / 2;

    window.setLocation(x, y);

    window.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();

    clipboard.setContents(new StringSelection("string"), null);
}

From source file:MainClass.java

public static void main(String[] args) {
    Toolkit tk = Toolkit.getDefaultToolkit();
    System.out.println("Color model = " + tk.getColorModel());

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    StringSelection ss = new StringSelection("str");
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    URL url = new URL("image address");
    Toolkit t = Toolkit.getDefaultToolkit();
    Image im = t.getImage(url);/*from  ww w.j av  a  2  s .  c  o m*/

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
    if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
        String text = (String) t.getTransferData(DataFlavor.stringFlavor);
        System.out.println(text);
    }//ww w. j a  va2s . c o  m

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    URL url = new URL("http://hostname:80/image.gif");

    Image image = Toolkit.getDefaultToolkit().getDefaultToolkit().createImage(url);
}

From source file:MainClass.java

public static void main(String[] unused) {
    JFrame f = new JFrame("FrameIcon");
    Image im = Toolkit.getDefaultToolkit().getImage("FrameIcon.gif");
    f.setIconImage(im);/*  w  ww  . java  2s. c o  m*/
    f.setSize(100, 100);
    f.setLocation(200, 200);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame();

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

    int width = (int) screenSize.getWidth();
    int height = (int) screenSize.getHeight();
    Dimension newDim = new Dimension(width, height - 40);

    frame.setSize(newDim);//from ww  w .jav a 2 s.com

    frame.setVisible(true); // FIRST visible = true
    frame.setResizable(false); // THEN resizable = false
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}