isVisible()是否可以确保UI对象在JAVA中的可见性 [英] Does isVisible() guarantees the visibility of the UI object in JAVA

查看:68
本文介绍了isVisible()是否可以确保UI对象在JAVA中的可见性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它的一般性问题.如果添加一些UI对象(例如JButton等)并检查isVisible属性,它将返回true.但是,是否可以保证该对象在显示器上实际渲染并正确可见?如果没有,是否有更好的方法来检查它?

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?

推荐答案

isVisible()仅仅是此组件本身的提示.用户是否真正看到它取决于组件的父级层次结构.可以通过Component继承的isShowing()来最好地验证这一点,该组件将检查组件及其所有父组件的isVisible()isDisplayable().但是正如javadoc所提到的那样,这并不能真正保证该组件对用户真正可见:

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:

  • 该组件已添加到可见的ScrollPane中,但该组件当前不在滚动窗格的查看端口中.

  • 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.

这篇关于isVisible()是否可以确保UI对象在JAVA中的可见性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆