重新验证JPanel的父框架 [英] Revalidate JPanel's parent frame
问题描述
我希望我的面板在显示/隐藏字段时适合框架.如何通知父框架重新验证?
I want my panel to fit the frame when I show/hide fields. How could I notify to the parent frame to revalidate?
我考虑过将框架传递给面板的构造函数,但我认为可能已经有一种方法可以完成.我记得在JPanel中有一个受保护的属性,但没有..也许我记得错误的组件.
I thought about pass the frame to my panel's constructor, but I think may have a way this is already done. I remember that there was a protected attribute in JPanel, but there isn't.. maybe i remembering the wrong component.
推荐答案
我需要显示/隐藏我的某些字段 面板,而我希望面板适合 框架.
I need show/hide some fields of my panel, and I want the panel to fit the frame.
您的意思是像摘要/详细信息视图一样,并且希望更改框架尺寸吗?然后尝试:
You mean like a summary/details view and you want the frame size to change? Then try:
SwingUtilities.windowForComponent(...).pack();
SwingUtilities.windowForComponent(...).pack();
这篇关于重新验证JPanel的父框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!