1 .问题说明
在一个教程中,我看到了GridBagConstraints中关于ipadx和ipady的说明:
ipadx,ipady
specifiestheinternalpadding 3360 howmuchtoaddtotheminimumsizeof
the component.thedefaultvalueiszero.thewidthofthecomponent
willbeatleastitsminimumwidthplusipadx *2pixels,since the
paddingappliestobothsidesofthecomponent.similarly,the height
ofthecomponentwillbeatleastitsminimumheightplusipady * 2像素。
我理解的大致意思是:
设置ipadx和ipady后得到的最终组件大小必须为(组件的最小宽度) ipadx or ipady) )
示例:
假设ipadx=10; ipady=10; 组件的默认宽度为30 * 40。
按以上说法,最终组件的大小为30 10*2() 30 10*2)。
出现的疑问
但是,我实际制作案例时得到的结果是:(305*2) ) *(40 5*2)
也就是说,实际上是均等地分配了ipadx或ipady组件的上下左右
问题是,我的理解是错的,教程本身是错的,还是有其他的理解?
原始教程地址: