java – JComponent.isShowing()和isDisplayable()之间的区别
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – JComponent.isShowing()和isDisplayable()之间的区别,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1401字,纯文字阅读大概需要3分钟。
内容图文
![java – JComponent.isShowing()和isDisplayable()之间的区别](/upload/InfoBanner/zyjiaocheng/698/7021f0aa017b44a08713c6fe27c7222f.jpg)
Component.isShowing()和Component.isDisplayable()有什么区别?我想用它们来决定我应该停止/启动一个Timer.
解决方法:
一个组件
isShowing()何时
Determines whether this component is showing on screen. This means
that the component must be visible, and it must be in a container that
is visible and showing.
isShowing()是递归的并且也检查所有父组件,但isDisplayable()和isVisible()仅验证组件的状态,而不验证其父组件的状态.
这意味着您的组件当前显示在框架,面板等的屏幕上.
setVisible(true) – > isShowing()返回true(在大多数情况下)
setVisible(false) – > isShowing()返回false(在所有情况下)
isDisplayable()何时
Determines whether this component is displayable. A component is
displayable when it is connected to a native screen resource.A component is made displayable either when it is added to a displayable
containment hierarchy or when its containment hierarchy is made
displayable. A containment hierarchy is made displayable when its
ancestor window is either packed or made visible.A component is made undisplayable either when it is removed from a
displayable containment hierarchy or when its containment hierarchy is
made undisplayable. A containment hierarchy is made undisplayable when
its ancestor window is disposed.
这意味着您的组件处于可以在屏幕上显示的状态,但它不需要当前显示在屏幕上以处于可显示状态.例如,即使之前在组件上调用了setVisible(false)(因此组件是“不可见的”),组件仍然可以显示,而isDisplayable()将返回true.
内容总结
以上是互联网集市为您收集整理的java – JComponent.isShowing()和isDisplayable()之间的区别全部内容,希望文章能够帮你解决java – JComponent.isShowing()和isDisplayable()之间的区别所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。