Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Its generic question. If I add some UI objects such as JButton etc and check the isVisible property, it would return true. However, does it guarantee that the object is actually rendered and visible correctly on the display? If not, is there some better way to check the same?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
270 views
Welcome To Ask or Share your Answers For Others

1 Answer

No isVisible() is only a hint for this component itself. If it is really visible for the user depends on the parent hierarchy of the component. This can be verified best by isShowing() inherited by Component, which checks isVisible() and isDisplayable() of the component and all it's parent components. But as the javadoc mentions even that does not really guarantee that the component is really really visible to the user:

Note: sometimes there is no way to detect whether the Component is actually visible to the user. This can happen when:

  • the component has been added to a visible ScrollPane but the Component is not currently in the scroll pane's view port.

  • the Component is obscured by another Component or Container.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...