Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
GUI.java
1 package ij.gui;
2 import java.awt.*;
3 import ij.*;
4 
6 public class GUI {
7 
9  public static void center(Window w) {
10  Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
11  Dimension window = w.getSize();
12  if (window.width==0)
13  return;
14  int left = screen.width/2-window.width/2;
15  int top = (screen.height-window.height)/4;
16  if (top<0) top = 0;
17  w.setLocation(left, top);
18  //ij.IJ.write("screen: "+screen);
19  //ij.IJ.write("window: "+window);
20  }
21 
22  static private Frame frame;
23 
25  public static Image createBlankImage(int width, int height) {
26  if (width==0 || height==0)
27  throw new IllegalArgumentException("");
28  if (frame==null) {
29  frame = new Frame();
30  frame.pack();
31  frame.setBackground(Color.white);
32  }
33  Image img = frame.createImage(width, height);
34  return img;
35  }
36 
37 }