是否可以在 GridBagLayout JPanel 中找到请求单元格 (x,y) 的当前尺寸(以像素为单位)?
编辑:我的用法是让 JLabel 填充布局提供的区域。我想给它提供给它的最大尺寸。
是否可以在 GridBagLayout JPanel 中找到请求单元格 (x,y) 的当前尺寸(以像素为单位)?
编辑:我的用法是让 JLabel 填充布局提供的区域。我想给它提供给它的最大尺寸。
My usage would be to have a JLabel that fills the area provided by the layout. I want to give it the maximum size made available to it.
That is the job of the layout manager. You are not supposed to specify the size of a component.
Read the section from the Swing tutorial on How to Use a GridBagLayout. You will want to specify the "fill" constraint when you add the component to the layout.
Maybe other layout managers can solve your problem as well. The tutorial has examples for all the layout mangers.