8/23/2023 0 Comments Windows 10 apps to screen mirror![]() ![]() Okay, the next issue to solve, is how to render the screen. See Worker Threads and SwingWorker for more details. It does most of the heavy lifting for us and provides a simplified workflow. With this in mind, I decided to go with a SwingWorker. See Concurrency in Swing for more details. This means you can't capture the snapshot from the Event Dispatching Thread and should not try to update the UI from outside of the Event Dispatching Thread. You need to be aware of the fact that Swing is not thread safe and is single threaded. Now, you need some way to produce and consume those snapshots. ![]() Once you have this information, you can use GraphicsDevice#getBounds to get the physical area of the screen, which you can feed to Robot I could have also used getBounds and tried to figure out where each screen was positioned, but what ever works. GraphicsDevice lstGDs = ge.getScreenDevices() GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment() So, I started by trying to look at the screen resolutions and tried to figure out which screen I wanted. ![]() The first thing you need to do though, is get the "area" of the screen you want to capture and this is not as easy it as might sound as Java doesn't seem to provide the "screen names" □ (on Windows GraphicsDevice#getIDstring might return the name, but on MacOS it didn't) You want to use an instance of Robot to capture a snapshot of the screen. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |