重新验证JPanel的父框架 [英] Revalidate JPanel's parent frame

查看:63
本文介绍了重新验证JPanel的父框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的面板在显示/隐藏字段时适合框架.如何通知父框架重新验证?

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屋!

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