[英]custom Swing components that resize dynamically but interoperate with LayoutManagers
I have a subclassed JPanel
that acts as a view for some information.我有一个子类
JPanel
作为一些信息的视图。
When the information changes, the min/max/preferred size of the JPanel
may change as well.当信息改变时,
JPanel
的最小/最大/首选大小也可能会改变。
How do I handle this event properly so that it plays nicely with a LayoutManager
?如何正确处理此事件,以便它与
LayoutManager
很好地配合?
I tried overriding getPreferredSize()
but it only seems to be called once.我尝试覆盖
getPreferredSize()
但它似乎只被调用一次。
Try revalidate your component after min/max/preferred size has been changed.在更改最小/最大/首选大小后尝试重新验证您的组件。 Should work.
应该管用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.