[英]Automatically resize JPanel without use BorderLayout.CENTER
I have a JPanel
inside a JDesktopPane
and I need to resize the panel automatically when the size of desktopPane changes. 我在
JDesktopPane
有一个JPanel
并且当desktopPane的大小更改时,我需要自动调整面板的大小。
The size of panel always needs to be the same of desktopPane
. 面板的大小始终需要与
desktopPane
相同。 I can't use BorderLayout.CENTER
because if I use it, I cant resize others frames inside of desktopPane
. 我无法使用
BorderLayout.CENTER
因为如果使用它,则无法调整desktopPane
内其他框架的desktopPane
。
Thanks 谢谢
Use a ComponentListener/Adapter 使用ComponentListener / Adapter
JDesktopPane desktop = ...;
JPanel p = ...;
ComponentListener cl = new ComponentAdapter() {
public void componentResized(ComponentEvent ce) {
//reset your panel size here
}
}
desktop.addComponentListener(cl);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.