简体   繁体   English

JPanel-仅设置最小高度

[英]JPanel - Set only a minimum height

I read that if a minimum size has not been set on a jpanel, a call to getMinimumSize will be delegated to the panel's layout manager. 我读到,如果未在jpanel上设置最小尺寸,则对getMinimumSize的调用将委派给面板的布局管理器。 If a minimum size is set on a panel, then this dimension will be returned when getMinimumSize is called, and not the layout manager's. 如果在面板上设置了最小尺寸,则在调用getMinimumSize而不是布局管理器的尺寸时将返回此尺寸。 I want to set only a minimum height on my JPanel and leave the retrieval of the minimum width to the panel's layout manager, as I want to leave the minimum width to be whatever the layout manager decides. 我只想在我的JPanel上设置一个最小高度,并将最小宽度的检索留给面板的布局管理器,因为我想将最小宽度保留为布局管理器决定的大小。 Is it possible to set only the minimum height on the JPanel? 是否可以仅在JPanel上设置最小高度?

Override getMinimumSize() method. 重写getMinimumSize()方法。 In the method call super and replace the height in the result. 在方法中调用super并替换结果中的高度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM