容器在组件可见之前将其删除
我正在开发一个包含很多组件的大型应用程序。我试图在一个地方添加一个组合框,而容器在该组件可见之前将其删除。我读到一些 Java Swing 验证并删除该组件(如果该组件被添加到其他地方)的内容。这究竟是如何运作的?
很抱歉,但我想这个问题太突然了,我无法提供任何代码。
PS检查了组件、面板和容器的每个属性,没有任何东西影响组件的可见性。
I am working on a big application with lots of components in it. I am trying to add a comboBox at one place and Container is removing that component before it is visible. I read some where that Java Swing validates and removes the component if it is aded somewhere else. How does that exactly works ?
I am sorry but I guess this problem is too abrupt and I am not able to provide any code.
P.S. checked every property of component,panel and container and there is nothing which is affecting the visibility of component.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我从来没有看到
Container 在可见之前删除该组件
,您如何调试该组件以及调试什么内容,您确定 JComboBox 已添加到预期的可见容器中吗?顺便说一句,有很多关于如何在运行时添加/删除 JComponent
此处< /a>是关于最近/最近帖子的指南,I never see that
Container is removing that component before it is visible
, how and what did you debug that, are you sure that JComboBox was added to the expected and visible Container, btw there are lots of threads aboutHow to Add/Remove JComponent(s) on Runtime
here is guide from last/recent posts about that,您所读到的是,您只能将组件添加到一个可视化容器中。如果将组件添加到多个容器中,它将仅在其中之一中可视化。除此之外,Swing 不会随机从容器中删除组件,因此,如果我提到的第一件事不是您的问题,那么您的程序中存在错误,我们需要查看代码来找出它是什么。最好是您可以创建并发布 SSCCE
What you've read is that you can add a component to only one visualized container. If you add the component to multiple containers it will only be visualized in one of them. Other than that, Swing will not randomly remove components from containers, so if the first thing that I mentioned is not your issue, you've got a bug in your program, and we'll need to see code to figure out what it is. Best would be if you could create and post an SSCCE