use of java.awt.Toolkit in project JSettlers2 by jdmonin.
the class SOCFaceButton method loadImages.
private static synchronized void loadImages(Component c) {
if (images == null) {
tracker = new MediaTracker(c);
Toolkit tk = c.getToolkit();
Class<?> clazz = c.getClass();
images = new Image[NUM_FACES];
robotImages = new Image[NUM_ROBOT_FACES];
/**
* load the images
*/
robotImages[0] = tk.getImage(clazz.getResource(IMAGEDIR + "/robot.gif"));
tracker.addImage(robotImages[0], 0);
for (int i = 1; i < NUM_FACES; i++) {
images[i] = tk.getImage(clazz.getResource(IMAGEDIR + "/face" + i + ".gif"));
tracker.addImage(images[i], 0);
}
for (int i = 1; i < NUM_ROBOT_FACES; i++) {
// Client possibly only has robot.gif.
// Check getResource vs null, and use MediaTracker;
// drawFace can check tracker.statusID vs MediaTracker.COMPLETE.
URL imgSrc = clazz.getResource(IMAGEDIR + "/robot" + i + ".gif");
if (imgSrc != null) {
robotImages[i] = tk.getImage(imgSrc);
tracker.addImage(robotImages[i], i);
}
}
try {
tracker.waitForID(0);
} catch (InterruptedException e) {
}
if (tracker.isErrorID(0)) {
System.out.println("Error loading Face images");
}
}
}
use of java.awt.Toolkit in project com.revolsys.open by revolsys.
the class Icons method getCursor.
public static Cursor getCursor(final String imageName, final int dx, final int dy) {
Image image = getImage(imageName);
if (image == null) {
return null;
} else {
final Toolkit toolkit = Toolkit.getDefaultToolkit();
if (OS.isWindows()) {
final BufferedImage newImage = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB);
final Graphics graphics = newImage.getGraphics();
graphics.drawImage(image, 0, 0, null);
graphics.dispose();
image = newImage;
}
return toolkit.createCustomCursor(image, new Point(dx, dy), imageName);
}
}
use of java.awt.Toolkit in project com.revolsys.open by revolsys.
the class SwingUtil method setSize.
static void setSize(final Window window, final int minusX, final int minusY) {
final Toolkit toolkit = Toolkit.getDefaultToolkit();
final Dimension screenSize = toolkit.getScreenSize();
final double screenWidth = screenSize.getWidth();
final double screenHeight = screenSize.getHeight();
final Dimension size = new Dimension((int) (screenWidth - minusX), (int) (screenHeight - minusY));
window.setBounds(minusX / 2, minusY / 2, size.width, size.height);
window.setPreferredSize(size);
}
use of java.awt.Toolkit in project freeplane by freeplane.
the class Launcher method fixX11AppName.
private static void fixX11AppName() {
try {
Toolkit xToolkit = Toolkit.getDefaultToolkit();
if (xToolkit.getClass().getName().equals("sun.awt.X11.XToolkit")) {
java.lang.reflect.Field awtAppClassNameField = xToolkit.getClass().getDeclaredField("awtAppClassName");
awtAppClassNameField.setAccessible(true);
awtAppClassNameField.set(xToolkit, "Freeplane");
}
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
System.err.format("Couldn't set awtAppClassName: %s%n", e.getClass().getSimpleName() + ": " + e.getMessage());
}
}
use of java.awt.Toolkit in project CS3243-Project by Kangqing-Qiu.
the class TLabel method setFont.
public void setFont(Font f) {
Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
double x = toolkit.getScreenSize().getWidth();
double y = toolkit.getScreenSize().getHeight();
double xscale = x / 1400.0;
double yscale = y / 1050.0;
double scale = Math.sqrt((xscale * xscale + yscale * yscale) / 2);
font = f.deriveFont((float) (f.getSize() * scale));
}
Aggregations