Removing space around buttons in GridBagLayout

落花浮王杯 提交于 2019-12-01 16:45:43

Noticed that the preferred height of the buttons doesn't seem to be calculated correctly for the buttons (in some cases).

In the cases where the height of the label is 40, the height of the button was 41.

Its like the button will always resize to an odd number?

I changed the code:

//int[] y = {0, 45, 85, 140, 180, 225, 265, 280, 320, 345};
int[] y = {0, 45, 86, 139, 180, 225, 266, 279, 320, 345};

and it seems to work.

Ah, just found the reason. You also need:

b.setFocusPainted(false);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!