예제 #1
0
 private void seticon() {
   Image icon;
   try {
     InputStream data = MainFrame.class.getResourceAsStream("icon.png");
     icon = javax.imageio.ImageIO.read(data);
     data.close();
   } catch (IOException e) {
     throw (new Error(e));
   }
   setIconImage(icon);
 }
예제 #2
0
  /** Do screen capture and save it as image */
  private static void captureScreenAndSave() {

    try {
      Robot robot = new Robot();
      Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      Rectangle rectangle = new Rectangle(0, 0, screenSize.width, screenSize.height);
      System.out.println("About to screen capture - " + rectangle);
      java.awt.image.BufferedImage image = robot.createScreenCapture(rectangle);
      javax.imageio.ImageIO.write(image, "jpg", new java.io.File("ScreenImage.jpg"));
      robot.delay(3000);
    } catch (Throwable t) {
      System.out.println("WARNING: Exception thrown while screen capture!");
      t.printStackTrace();
    }
  }