0

I have a program written in JAVA that creates a JPG file at a specified path whenever PRINTSCREEN is pressed. This program runs in background and uses the JIntellitype API.

My problem is that:

screensize = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());

is the only available function I could find to get the screen size which I later use to get a buffered image like this:

bf = screenRobot.createScreenCapture(screensize);

where bf is a BufferedImage data type.

Is there any way that I could get the screensize of the window that is currently active so that unwanted content is not saved in the JPG file?

ritratt
  • 1,703
  • 4
  • 25
  • 45
  • Try this, http://stackoverflow.com/questions/8333187/how-to-check-current-window-size-in-java-swing – Amarnath Sep 28 '12 at 13:19

1 Answers1

1
Frame.getX()
Frame.getY()
Frame.getWidth()
Frame.getHeight()
Adam Dyga
  • 8,666
  • 4
  • 27
  • 35
  • I do not want the size of my application. I want the size of the window currently active. This could be a browser, notepad etc. – ritratt Sep 28 '12 at 12:44
  • 2
    This might be more difficult. I don't think there is any standard Java library that does it. It may be necessary to call native OS code to do that. – Adam Dyga Sep 28 '12 at 12:50