Does isVisible() guarantees the visibility of the UI object in JAVA

不想你离开。 提交于 2019-12-25 06:04:37

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/16812112/does-isvisible-guarantees-the-visibility-of-the-ui-object-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!