-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPixelInfo.java
More file actions
44 lines (36 loc) · 1.31 KB
/
Copy pathPixelInfo.java
File metadata and controls
44 lines (36 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Background;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import java.awt.*;
public class PixelInfo extends Application {
static Robot robot;
public static void main(String[] args) {
try{
robot = new Robot();
}catch(AWTException ignore){}
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
VBox vb = new VBox();
vb.setBackground(Background.EMPTY);
vb.setStyle("-fx-border-color:blue;");
vb.setOnMouseClicked(e -> {
System.out.print(e.getScreenX() + " : " + e.getScreenY());
Thread thread = new Thread( () -> {
java.awt.Color color = robot.getPixelColor((int) e.getScreenX(), (int) e.getScreenY());
System.out.println(" -- r: " + color.getRed() + " | g: " + color.getGreen() + " | b: " + color.getBlue());
});
thread.start();
});
Scene scene = new Scene(vb, 300, 300);
scene.setFill(Color.TRANSPARENT);
primaryStage.setScene(scene);
primaryStage.initStyle(StageStyle.TRANSPARENT);
primaryStage.show();
}
}