Java: find out if an applet is displayed on the screen

I am trying to write an applet in Java that checks if it is displayed on the screen. There are several ways to check if Java wants to show the applet or certain components (i.e. .isShowing() or .isVisible() ), but none of them checks if the application is really displayed on the screen.

Say you launch the applet in Tab A of your favorite browser. When you go to Tab B, the applet no longer appears, but it still works (applet.stop () will not be called in this case). Or, when you have a page with an applet, but move it before it. I need to check if the applet is really visible to the user, and not hidden by anything else (for example, behind another application).

I think there is no easy way in java to do this since I have been looking for the last two days for it;) Can someone tell me some way to achieve this? Your help would be greatly appreciated.

+4
source share
2 answers

I do not have much experience working with applets, but from what I understand, you do not need to check if it is Visible or Showing , you need to check whether it is active. Check this java code -> Java code

Or you could detect the ringing on the screen and determine when the mouse will exceed it. Thus, in this case, you will find out if the user is working on something else, even if the applet is showing. (the user simultaneously opens two browsers on the screen)

0
source

I resolved this issue using Frame.isFocused() .

0
source

Source: https://habr.com/ru/post/1434997/


All Articles