Can I find out if the JFrame is fully visible?

I'm just experimenting with JFrames and would like to know if my application window is completely visible or closed by some other application window. Another application window may be a native application. If possible, can I get the size and position of the area that is not visible?

+3
source share
2 answers

Here is a really nasty approach , which is the only approach I can come up with (and don't recommend):

  • Set the glass panel JFramecompletely red and show the glass panel (temporarily).
  • Use the class Robotto select all pixels (or several pixels) from the coordinate of the screen where yours is located JFrame.
  • If all of your samples (or most of the samples according to some threshold) are red, then most likely nothing will be in front of yours JFrame.
  • Finally, hide the glass.

Alternative (more pleasant solution)

Just call toFront()your own JFrameto bring him to the front and make sure he has focus.

+1
source

, , Java- . . Unix- , Linux, - . .

, ? /, . , , .

0

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


All Articles