Former HPE Products
cancel
Showing results for 
Search instead for 
Did you mean: 

Robot.createScreenCapture does not capture dock and top bar in gnome-shell

 
masonjames
Occasional Contributor

Robot.createScreenCapture does not capture dock and top bar in gnome-shell

I am creating a screen share program in Java, but I have a problem: the method that I use to take the screen capture, Robot.createScreenCapture, does not capture the entire screen. I am using the official Oracle JDK 8 with OpenJFX, and I am running Ubuntu 17.04 with gnome-shell 3.24.1 on an HP Pavilion Elite HPE desktop computer.

The dock and top bar are black. Here is a screenshot taken by Robot.createScreenCapture: 

2s1xy

This simple code was used to take it:

import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;

public class ScreenGrab {
  public static void main(String[] args) {
    try {
        Thread.sleep(5000);
      Rectangle grabRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
      Robot robot = new Robot();
      BufferedImage capture = robot.createScreenCapture(grabRect);
      ImageIO.write(capture, "PNG", new File("java-screen-shot.png"));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

The closest thing I could find to my problem is this bug in OpenJDK with Oracle SQL. I also couldn't find any screenshot libraries.

Every question on SO that asked about a Java screenshot library was referred to Robot.createScreenCapture.

Can you help me figure this out?

Thanks!

1 REPLY 1
Parvez_AL
Community Manager

Re: Robot.createScreenCapture does not capture dock and top bar in gnome-shell

Hi,

HPE software are now part of a new company, Micro Focus. So you will need to repost your question to the new Micro Focus Community at https://community.softwaregrp.com/
Or,

If it is related to HP Desktop then you'll have to register and post your query in HP Inc Support Forum.

Here is the link:

https://h30434.www3.hp.com/

 

Thanks,
Parvez_AL
I am a HPE Employee
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
CM_Cert_Logo_Color.png