The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.swing  [141 examples] > The Screen  [2 examples]

e864. Capturing a Screen Shot

See also e670 Converting a Buffered Image to an Image.
    try {
        Robot robot = new Robot();
    
        // Capture a particular area on the screen
        int x = 100;
        int y = 100;
        int width = 200;
        int height = 200;
        Rectangle area = new Rectangle(x, y, width, height);
        BufferedImage bufferedImage = robot.createScreenCapture(area);
    
        // Capture the whole screen
        area = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
        bufferedImage = robot.createScreenCapture(area);
    } catch (AWTException e) {
    }

 Related Examples
e865. Converting Between Component and Screen Coordinates

See also: Actions    JButton    JCheckBox    JComboBox    JDesktop and JInternalFrame    JFrame, JWindow, JDialog    JLabel    JList    JProgressBar    JRadioButton    JScrollPane    JSlider    JSpinner    JSplitPane    JTabbedPane    JToolBar    Keystrokes and Input Maps    Layout    Look and Feel    Menus    Progress Monitor    Tool Tips    UI Default Values   


© 2002 Addison-Wesley.