File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed
src/main/java/dev/elektronisch/screenshot Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 6
6
7
7
<groupId >dev.elektronisch</groupId >
8
8
<artifactId >screenshotTool</artifactId >
9
- <version >1.1 </version >
9
+ <version >1.2 </version >
10
10
11
11
<properties >
12
12
<maven .compiler.source>1.8</maven .compiler.source>
Original file line number Diff line number Diff line change 19
19
20
20
public final class ScreenshotToolApplication {
21
21
22
- private static final double CURRENT_VERSION = 1.1 ;
22
+ private static final double CURRENT_VERSION = 1.2 ;
23
23
24
24
private final DefaultListModel <String > urlListModel = new DefaultListModel <>();
25
25
private final int [] emptyIntArray = new int []{};
@@ -59,7 +59,7 @@ private void addWindowComponents() {
59
59
frame .setVisible (false );
60
60
try {
61
61
Thread .sleep (200 );
62
- final BufferedImage image = ScreenCaptureUtil .captureScreen ();
62
+ final BufferedImage image = ScreenCaptureUtil .captureScreen (frame . getX (), frame . getY () );
63
63
urlListModel .add (0 , "Hochladen ..." );
64
64
frame .setVisible (true );
65
65
Original file line number Diff line number Diff line change 6
6
public final class ScreenCaptureUtil {
7
7
8
8
private static Robot robot ;
9
- private static Rectangle screenRectangle ;
9
+ private static GraphicsEnvironment environment ;
10
10
11
11
static {
12
12
try {
13
13
robot = new Robot ();
14
- screenRectangle = new Rectangle ( Toolkit . getDefaultToolkit (). getScreenSize () );
14
+ environment = GraphicsEnvironment . getLocalGraphicsEnvironment ( );
15
15
} catch (final AWTException ignored ) {
16
16
}
17
17
}
18
18
19
19
private ScreenCaptureUtil () {
20
20
}
21
21
22
- public static BufferedImage captureScreen () {
23
- return robot .createScreenCapture (screenRectangle );
22
+ public static BufferedImage captureScreen (final int x , final int y ) {
23
+ for (final GraphicsDevice device : environment .getScreenDevices ()) {
24
+ final GraphicsConfiguration configuration = device .getConfigurations ()[0 ];
25
+ final Rectangle bounds = configuration .getBounds ();
26
+ if (x >= bounds .getMinX () && x <= bounds .getMaxX ()) return robot .createScreenCapture (bounds );
27
+ }
28
+ return null ;
24
29
}
25
30
}
You can’t perform that action at this time.
0 commit comments