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;
}
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;
}
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");
}
}
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");
}
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);
}
Aggregations