Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use java.awt.Robot to capture the pixels that are currently visible on the desktop. To get the area behind your Java window, first hide, minimize, move, or otherwise remove that window from the target rectangle, wait for the desktop to repaint, capture a Rectangle in screen coordinates, and restore the window in a finally block. A normal screen capture cannot see pixels occluded by a foreground window while that window remains visible.

What “behind the Java application” means

Robot.createScreenCapture(Rectangle) reads pixels from the composed screen. It does not ask another application for an off-screen rendering of its window. Consequently, if your Java frame covers the target area, the image contains your Java frame. The reliable portable sequence is:

  1. Confirm that the process has access to a graphical desktop.
  2. Choose the monitor and rectangle to capture.
  3. Save the Java window’s location, size, and visibility state.
  4. Hide, minimize, or move the window away from the rectangle.
  5. Wait briefly for the window manager/compositor to repaint.
  6. Capture on a worker thread, not the Swing Event Dispatch Thread (EDT).
  7. Restore the original window state in finally.

If the requirement is to capture a hidden or occluded application’s content without changing visibility, use that operating system’s window-capture API instead. Robot alone is not an occlusion bypass.

Minimal Java implementation

The following example displays a small always-on-top frame. Clicking the button hides it, captures the entire virtual desktop, writes behind.png, and restores the frame even when capture fails.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Guermok Video Capture Card, 4K USB3.0 HDMI to USB C, 1080P 60FPS & 2K 30FPS
  • 【1080P 60FPS Video Capture Card】 This HDMI game capture card is based on USB3.0 high speed transmission port, input resolution up to 4K@30HZ, output resolution up to 2K@30Hz or 1920×1080@60Hz. Type c and USB interface can meet most of the devices in daily life. Easily meet the online capture, real-time recording, online meetings, live gaming and other functions, so you have a better visual enjoyment. Note: For capture use only; requires capture software to function and is not intended for direct screen casting to a monitor or TV
  • 【Ultra Low Latency Screen Sharing】 HDMI capture card is made of good quality aluminum alloy with strong heat dissipation, allowing you to enjoy ultra low latency while live gaming or video recording or live streaming, avoiding blue screens and lag. This HDMI to USBC capture card supports easy recording of good quality audio or HD video and transferring it to your computer or streaming platform, allowing you to record 60 fps HD video directly on your hard drive and real-time preview
  • 【Plug and Play, Easy to Carry】 This HDMI 1080P video capture card does not require any additional drivers or external power supply, just plug and play for fast capture. The capture card is small and lightweight, so you can put it in your bag for emergencies, making it very portable for outdoor live streaming. It's also a great way to share content in game recording, video conference, video recorder and online teaching
  • 【Wide Compatibility USB Capture Card】 Easily streams to Facebook, Youtube or Twitch. With the connection, this HDMI to USB C/3.0 video capture devices can be working on several Operating Systems and various software: Windows 7/ 8/ 10, Mac OS or above, Linux, Android, Laptop, Xbox One, PS3/PS4/PS5, Camera, DVDs, Set Top Box, Webcame, DSLR, Switch/Switch 2, TV BOX, HDTV, Potplayer/VLC, ZOOM, OBS Studio etc.
  • 【Package Content & Note】 1x HD Audio Capture Card , 1x USB 3.0 to USB C Adapter (A-side 3.0, B-side 2.0), 1x user manual. Please note that you need to restart the OBS Studio software after the audio setup is complete, otherwise it will result in no sound output. When using an adapter, if the device is recognized as USB 2.0, try using the other side with the USB-C port. Simply flip the capture card and reconnect it to be recognized as USB 3.0
import java.awt.AWTException;
import java.awt.BorderLayout;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;

public final class BehindCaptureDemo {
    private final JFrame frame = new JFrame("Capture controller");

    private BehindCaptureDemo() {
        JButton capture = new JButton("Capture behind this window");
        capture.addActionListener(event -> captureBehind());
        frame.add(new JLabel("The frame is removed before capture."), BorderLayout.NORTH);
        frame.add(capture, BorderLayout.CENTER);
        frame.setAlwaysOnTop(true);
        frame.setSize(360, 120);
        frame.setLocationByPlatform(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }

    private void captureBehind() {
        // Do not block the EDT while Robot captures the screen.
        Thread worker = new Thread(() -> {
            boolean wasVisible = frame.isVisible();
            int oldState = frame.getExtendedState();
            try {
                Rectangle area = virtualDesktopBounds();
                SwingUtilities.invokeAndWait(() -> frame.setVisible(false));
                // Tune this for the target compositor; it is not a guaranteed delay.
                Thread.sleep(150);

                Robot robot = new Robot();
                BufferedImage image = robot.createScreenCapture(area);
                ImageIO.write(image, "png", new File("behind.png"));
                System.out.println("Saved behind.png: " + area);
            } catch (AWTException e) {
                System.err.println("Desktop capture is unavailable: " + e.getMessage());
            } catch (SecurityException e) {
                System.err.println("The operating system denied screen capture: " + e.getMessage());
            } catch (IOException e) {
                System.err.println("Could not write behind.png: " + e.getMessage());
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                try {
                    SwingUtilities.invokeAndWait(() -> {
                        frame.setExtendedState(oldState);
                        frame.setVisible(wasVisible);
                        frame.toFront();
                    });
                } catch (Exception restoreError) {
                    restoreError.printStackTrace();
                }
            }
        }, "screen-capture");
        worker.start();
    }

    private static Rectangle virtualDesktopBounds() {
        Rectangle result = new Rectangle();
        for (GraphicsDevice device : GraphicsEnvironment
                .getLocalGraphicsEnvironment().getScreenDevices()) {
            GraphicsConfiguration configuration = device.getDefaultConfiguration();
            result = result.union(configuration.getBounds());
        }
        return result;
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(BehindCaptureDemo::new);
    }
}

Compile and run it with a desktop JDK. The resulting image is the visible desktop after the frame has been removed. If you only need one monitor, use that device’s configuration bounds instead of the union returned by virtualDesktopBounds().

Choosing the capture rectangle and monitor

One display

GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() identifies the default display. Its GraphicsConfiguration.getBounds() supplies the monitor’s screen-coordinate rectangle. Constructing new Robot(device) makes the intended graphics device explicit.

GraphicsDevice device = GraphicsEnvironment
        .getLocalGraphicsEnvironment()
        .getDefaultScreenDevice();
Rectangle monitor = device.getDefaultConfiguration().getBounds();
Robot robot = new Robot(device);
BufferedImage image = robot.createScreenCapture(monitor);

Several displays

Some platforms expose monitors as one virtual desktop, including negative coordinates for a display positioned to the left or above the primary display. Other environments expose independent coordinate spaces. Do not assume that (0, 0) is the top-left corner of every monitor. Keep the rectangle and the selected GraphicsDevice in the coordinate system expected by that platform, and verify the result on each deployment target.

Rank #2
Audio Express AXHDCAP 4K HDMI Video Capture Card, Cam Link Card Game Audio Adapter HDMI to USB 2.0 Record Capture Device for Streaming, Live Broadcasting, Video Conference, Teaching, Gaming
  • [Enhanced 4K-1080P Video Capture Experience] Capture the Magic: Elevate your video recordings to new heights with our upgraded anti-static 1080P Video Capture Card. Immerse yourself in stunning visuals, supporting HDMI input at 4K 60FPS and USB output for capturing in 1080P, complete with rich stereo sound. Enjoy crystal-clear video recordings, dynamic gaming live streams, and professional conference broadcasts. Note: HDMI resolution: Max input can be 3840×2160@30Hz / Video output resolution: Max output can be 1920×1080@30Hz
  • [Seamless Real-Time Preview] Stay in the Moment: Our advanced ultra-low latency technology ensures seamless real-time transmission of video streams. Experience instant, lag-free previews, allowing you to capture every detail precisely. Effortlessly record video directly to your hard disk, all without compromising on quality or introducing any delays.
  • [Versatility and Broad Compatibility] Your Creative Hub: Connect your DSLR, camcorder, or action camera to a wide range of operating systems, including Windows, MacOS, and Linux. Unlock a world of possibilities with real-time streaming to popular platforms like Twitch, Youtube, OBS, Zoom, Potplayer, and VLC, giving you the tools to share your content effortlessly.
  • [Effortless Plug and Play] Simplicity Redefined: Say goodbye to complex installations. Our plug-and-play design eliminates the need for drivers or external power supplies. Seamlessly integrate high-definition acquisition into various scenarios, whether it's educational recordings, immersive gaming, precise medical imaging, captivating live streams, or professional broadcasting.
  • [Seize Every Detail with Precision] Unleash your creativity and attention to detail with our video capture card. Capture every nuance, every color, and every moment with precision, thanks to the enhanced capabilities of our technology. Whether you're a content creator, a gamer, or a professional, our capture card empowers you to seize the finest elements and bring them to life in your recordings and live streams.

A specific region

Use the target window’s bounds, a known region, or a rectangle calculated from a monitor’s bounds:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rectangle region = new Rectangle(200, 100, 1280, 720);
BufferedImage image = new Robot().createScreenCapture(region);

The rectangle is in screen coordinates, not Java component coordinates. A component’s getX() and getY() values are relative to its parent; use the window’s on-screen location or a graphics configuration’s bounds when converting.

High-DPI and multi-resolution output

Display scaling can make logical Java coordinates differ from the physical pixel dimensions in the saved image. On environments that support it, Robot.createMultiResolutionScreenCapture(Rectangle) returns resolution variants; select the variant appropriate for your output size. If exact pixel dimensions matter, test with the actual scaling settings used by customers rather than assuming a one-to-one mapping.

Rank #3
Video Capture Card, 4K USB3.0 HDMI to USB C, 1080P60FPS HDMI Capture Card for Streaming, Gaming, Video Recording Compatible with Switch, Xbox, PS4/5, OBS,iPad Mac OS Windows,Camera, Zoom(Silver)
  • 【4K HDMI Input, 2K@30Hz Recording】Powered by a true USB 3.0 high-speed interface, the capture card supports up to 4K@30Hz HDMI input and records at 2K@30Hz or 1080P@60Hz. Perfect for gamers, streamers, and professionals who need crisp, smooth video for live streaming, gameplay recording, or online meetings.
  • 【Ultra Low Latency Screen Sharing】Built with a premium aluminum alloy shell and advanced chipset for stable heat dissipation, ensuring ultra-low latency transmission. Capture high-quality video and dual-channel audio in real time—no lag, no frame drop—ideal for Twitch, YouTube, or OBS streaming.
  • 【Easy Plug and Play, Compact & Portable】No driver or external power required—just plug and play via USB 3.0 or Type-C connection to your Windows or macOS computer. Lightweight and compact design makes it easy to carry for outdoor streaming, live shows, or mobile recording setups.
  • 【Wide Compatibility & Multi-Device Support】Compatible with Windows 7 8 10 11, macOS, Linux,Android and supports most popular software such as OBS, Zoom, VLC, Twitch Studio, and more. Works seamlessly with PS4, PS5, Xbox, Switch, DSLR cameras, TV boxes, and other HDMI-output devices for streaming to YouTube, Twitch, etc.
  • 【What You Get】Includes: HDMI Capture Card, USB 3.0 to USB-C Adapter, User Manual. Tips: Make sure your tablet’s OTG function is enabled before connecting. Test your HDMI device with a monitor first to confirm video and audio output, then connect to the Video Capture Card for recording.

Record the rectangle, device, scaling mode, and resulting image dimensions in diagnostics. That information makes reports of cropped or unexpectedly large images actionable.

Window handling that does not leave the UI broken

Hide, minimize, or move

Hiding is usually the least intrusive visually, but it can trigger layout or repaint work. Minimizing may alter compositor behavior. Moving the frame outside the target rectangle avoids a visibility transition but can fail when the desktop has no spare area. Choose the method that your application can restore reliably.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Always-on-top windows

An always-on-top frame remains in the capture if it overlaps the rectangle. Turn off always-on-top or hide/minimize/move the frame before capture. Do not merely move keyboard focus; focus does not change which pixels are composited.

Rank #4
Capture Card, 4K HDMI Video Capture Card, Game Capture Card, 1080P 60FPS Video Capture Device, HDMI to USB 3.0 Capture Card for Streaming, Work with Camera/Xbox/PS4/PS5/PC/OBS
  • 【1080P HD High Quality】Capture resolution up to 1080p for video source and it is ideal for all HDMI devices such as PS4, PS3, Xbox One, Xbox 360, Wii U, DVDs, DSLR, Camera, Security Camera and set top box. Note: Video input supports 4K30/60Hz and 1080p120/144Hz. Does not support 4K120Hz/144Hz. Output supports up to 2K30Hz.
  • 【Plug and Play】No driver or external power supply required, true PnP. Once plugged in, the device is identified automatically as a webcam. Detect input and adjust output automatically. Won't occupy CPU, optional audio capture. No freeze with correct setting.
  • 【Compatible with Multiple Systems】suitable for Windows and Mac OS. High speed USB 3.0 technology and superior low latency technology makes it easier for you to transmit live streaming to Twitch, Youtube, Facebook, Twitter, OBS, Potplayer and VLC.
  • 【HDMI LOOP-OUT】Based on the high-speed USB 3.0 technology, it can capture one single channel HD HDMI video signal. There is no delay when you are playing game live.
  • 【Support Mic-in for Commentary】Rybozen capture card has microphone input and you can use it to add external commentary when playing a game. Please note: it only accepts 3.5mm TRS standard microphone headset.

Restoration

Always restore in finally. Restore visibility, extended state, location, size, and always-on-top status if you changed them. If capture is cancelled, the same restoration path should run. Invoke Swing state changes on the EDT, while the potentially lengthy capture remains on a worker thread.

Permissions, headless systems, and platform policy

  • Headless execution: a server, container, service session, or virtual machine without a graphical desktop may make Robot construction fail with AWTException. A display server and an interactive session are prerequisites.
  • Permission denial: operating-system privacy controls can throw SecurityException or leave the returned image undefined. Tell the user which desktop-capture permission to enable and retry only after permission is granted.
  • Remote desktops and virtual machines: session isolation, locked screens, compositor settings, and virtual display drivers can change what is visible. Validate the deployment environment instead of treating a local result as universal.
  • Wayland/X11 and similar policies: desktop portals or compositor restrictions may limit ordinary screen reads. A platform-specific capture path may be required.
  • Pointer visibility: the captured image does not include the mouse cursor.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Timing and performance

Screen capture can be expensive for large, high-density rectangles. Capture only the area you need, avoid unnecessary PNG compression on a latency-sensitive path, and release references to large BufferedImage objects after use. Never call capture from the EDT; Oracle specifically cautions that it may be a lengthy operation.

A fixed sleep is only a starting point. After hiding the window, wait long enough for the compositor to repaint on the slowest supported machine. For a more deterministic workflow, use an application-level acknowledgement (for example, complete the hide operation, then wait for a scheduled worker delay) and validate the image rather than assuming that a particular millisecond value works everywhere.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Capture Card, USB Video Capture Card Device, Audio Video Converter Grabber for RCA to USB-Convert VHS Mini DV VCR Hi8 DVD to Digital, for PC TV Tape Player Camcorder, MAC Windows Vista Compatible
  • AV TO USB Converter: Capture videos and audios from VHS, VCR, Hi8, DV tapes to a PC, with the help of our USB Video Converter. Save room while digitizing your favorite old memories
  • Quality Capture Card: Our USB Video Capture Card converting anolog RCA composite input into HD 720P USB output and capturing audio without any sound card. Advanced signal processing technology provides you with great precision, colors, resolutions, and details.
  • Plug and Play: Automatically install the driver once you hook up this RCA to USB Converter to a PC. No external power is needed. User-friendly and easy to operate
  • Wide Compatibility: The Video Capture Card can work with video devices with RCA connector or S-Video connector, such as VHS, VCR, Hi8, camcorder, compatible with Windows and Mac OS. Support video formats like NTSC, PAL, and support brightness, contrast, hue, and saturation control
  • Note: The Video Converter is used with acquisition software. We recommend OBS Studio or PotPlayer for Windows, and QuickTime Player for Mac. They can be downloaded for free online. Please operate according to the steps in User Manual or contact us if you have any questions

Troubleshooting

Symptom Likely cause Fix
The Java frame appears in the image It still overlaps the rectangle, or repaint had not completed. Hide/minimize/move it, wait for compositor repaint, and capture a rectangle that matches the intended monitor.
AWTException while creating Robot No usable graphical device or low-level desktop control. Run inside an interactive graphical session and verify the display/virtual-machine configuration.
SecurityException or blank/undefined image Screen-recording permission was denied. Enable the operating system’s screen-capture permission for the Java runtime or application, then retry.
Capture freezes the interface Capture or image encoding runs on the EDT. Move Robot and ImageIO.write to a worker thread; marshal only Swing changes to the EDT.
Wrong monitor or cropped output Mixed coordinate spaces, negative monitor coordinates, or scaling. Use the selected device’s configuration bounds, log coordinates, and test the actual multi-monitor/DPI arrangement.
Image shows stale desktop content The compositor had not repainted after the window was hidden. Increase the platform-tuned delay and ensure the hide operation completed before capture.
Works locally but not in production Production is headless, remote, locked, or subject to different desktop policy. Provision a supported graphical session or use the target platform’s capture API.

When a platform-specific API is the better choice

Choose Robot when you need a portable capture of visible desktop pixels and can temporarily remove your own window. Investigate a native window-content API when you need any of the following:

  • content from a window that remains covered;
  • capture of a minimized or hidden window;
  • application-specific fidelity rather than the final desktop composition;
  • cursor, window metadata, or compositor features that Robot does not provide.

Native APIs trade portability for control and bring their own permission, version, and window-manager differences. Keep the platform branch separate from the portable Robot implementation and test each supported operating system.

Or skip the browser setup

If what you actually need is a screenshot of a web page—not pixels behind a local Java window—ScreenshotNeo provides a single HTTP request. It accepts consent banners like a visitor, removes more than 60 known consent platforms plus newsletter popups and chat widgets before capture, and bills only clean shots. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and billing status. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.

See the parameter reference in the ScreenshotNeo documentation. The same request can return PNG, JPEG, WebP, or PDF, with options for full-page lazy-image loading, CSS-selector element capture, dark mode, device presets, retina scale, custom CSS/JavaScript, clicks, waits, blocked resources, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, caching, signed links, asynchronous jobs, webhooks, bulk capture, usage reporting, and an OpenAPI specification.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

cURL

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is on every plan, and yearly billing provides two months free. Create a free ScreenshotNeo account to try it.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.