Search in sources :

Example 56 with Toolkit

use of java.awt.Toolkit in project adempiere by adempiere.

the class Adempiere method getImageLogo.

//  getImageLogoSmall
/**
	 *  Get Logo Image.
	 *  @return Image Logo
	 */
public static Image getImageLogo() {
    if (s_imageLogo == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        URL url = org.compiere.Adempiere.class.getResource(s_file100x30);
        //	System.out.println(url);
        if (url == null)
            return null;
        s_imageLogo = tk.getImage(url);
    }
    return s_imageLogo;
}
Also used : Toolkit(java.awt.Toolkit) URL(java.net.URL)

Example 57 with Toolkit

use of java.awt.Toolkit in project adempiere by adempiere.

the class MImage method getImage.

/**
	 * 	Get Image
	 *	@return image or null
	 */
public Image getImage() {
    if (m_image != null)
        return m_image;
    //	Via byte array
    byte[] data = getBinaryData();
    if (data != null && data.length > 0) {
        try {
            BufferedImage bufferedImage = ImageIO.read(new ByteArrayInputStream(data));
            m_image = bufferedImage;
            return m_image;
        } catch (IOException e) {
            log.log(Level.WARNING, "(byteArray)", e);
            return null;
        }
    /*try
			{
				Toolkit tk = Toolkit.getDefaultToolkit();
				m_image = tk.createImage(data);
				MediaTracker mediaTracker = new MediaTracker(new Container());
                mediaTracker.addImage(m_image, 0);
                mediaTracker.waitForID(0);
				return m_image;
			}
			catch (Exception e)
			{
				log.log(Level.WARNING, "(byteArray)", e);
				return null;
			}*/
    }
    //	Via URL
    URL url = getURL();
    if (url == null)
        return null;
    try {
        Toolkit tk = Toolkit.getDefaultToolkit();
        m_image = tk.getImage(url);
        MediaTracker mediaTracker = new MediaTracker(new Container());
        mediaTracker.addImage(m_image, 0);
        mediaTracker.waitForID(0);
        return m_image;
    } catch (Exception e) {
        log.log(Level.WARNING, "(URL)", e);
    }
    return null;
}
Also used : MediaTracker(java.awt.MediaTracker) Container(java.awt.Container) ByteArrayInputStream(java.io.ByteArrayInputStream) Toolkit(java.awt.Toolkit) IOException(java.io.IOException) BufferedImage(java.awt.image.BufferedImage) URL(java.net.URL) IOException(java.io.IOException)

Example 58 with Toolkit

use of java.awt.Toolkit in project jdk8u_jdk by JetBrains.

the class MaximizedToMaximized method main.

public static void main(String[] args) throws Exception {
    Frame frame = new Frame();
    final Toolkit toolkit = Toolkit.getDefaultToolkit();
    final GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsDevice graphicsDevice = graphicsEnvironment.getDefaultScreenDevice();
    final Dimension screenSize = toolkit.getScreenSize();
    final Insets screenInsets = toolkit.getScreenInsets(graphicsDevice.getDefaultConfiguration());
    final Rectangle availableScreenBounds = new Rectangle(screenSize);
    availableScreenBounds.x += screenInsets.left;
    availableScreenBounds.y += screenInsets.top;
    availableScreenBounds.width -= (screenInsets.left + screenInsets.right);
    availableScreenBounds.height -= (screenInsets.top + screenInsets.bottom);
    frame.setBounds(availableScreenBounds.x, availableScreenBounds.y, availableScreenBounds.width, availableScreenBounds.height);
    frame.setVisible(true);
    Rectangle frameBounds = frame.getBounds();
    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    ((SunToolkit) toolkit).realSync();
    Rectangle maximizedFrameBounds = frame.getBounds();
    if (maximizedFrameBounds.width < frameBounds.width || maximizedFrameBounds.height < frameBounds.height) {
        throw new RuntimeException("Maximized frame is smaller than non maximized");
    }
}
Also used : Frame(java.awt.Frame) GraphicsDevice(java.awt.GraphicsDevice) Insets(java.awt.Insets) Rectangle(java.awt.Rectangle) SunToolkit(sun.awt.SunToolkit) SunToolkit(sun.awt.SunToolkit) Toolkit(java.awt.Toolkit) Dimension(java.awt.Dimension) GraphicsEnvironment(java.awt.GraphicsEnvironment)

Example 59 with Toolkit

use of java.awt.Toolkit in project jdk8u_jdk by JetBrains.

the class Permissions method main.

public static void main(String[] args) {
    MySecurityManager sm = MySecurityManager.install();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    sm.prepare("Toolkit.getSystemClipboard()");
    toolkit.getSystemClipboard();
    sm.assertChecked(AWTPermission.class, "accessClipboard");
    sm.prepare("Toolkit.getSystemEventQueue()");
    toolkit.getSystemEventQueue();
    sm.assertChecked(AWTPermission.class, "accessEventQueue");
    sm.prepare("Toolkit.getSystemSelection()");
    toolkit.getSystemSelection();
    //sm.assertChecked(AWTPermission.class, "accessClipboard");
    sm.prepare("Window(Frame)");
    new Window((Frame) null);
    sm.assertChecked(AWTPermission.class, "showWindowWithoutWarningBanner");
    sm.prepare("Window(Window)");
    new Window((Window) null);
    sm.assertChecked(AWTPermission.class, "showWindowWithoutWarningBanner");
    sm.prepare("Window(Window,GraphicsConfiguration)");
    new Window((Window) null, (GraphicsConfiguration) null);
    sm.assertChecked(AWTPermission.class, "showWindowWithoutWarningBanner");
}
Also used : Window(java.awt.Window) Toolkit(java.awt.Toolkit)

Example 60 with Toolkit

use of java.awt.Toolkit in project jdk8u_jdk by JetBrains.

the class LUTCompareTest method main.

public static void main(String[] args) throws IOException {
    Image img = createTestImage();
    Toolkit tk = Toolkit.getDefaultToolkit();
    LUTCompareTest o = new LUTCompareTest(img);
    tk.prepareImage(img, -1, -1, o);
    while (!o.isImageReady()) {
        synchronized (lock) {
            try {
                lock.wait(200);
            } catch (InterruptedException e) {
            }
        }
    }
    checkResults(img);
}
Also used : Toolkit(java.awt.Toolkit) IIOImage(javax.imageio.IIOImage) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage)

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