在Jframe中将Jbutton居中-Java

问题描述

我想在一个JPanel中手动居中多个JButton,但我的像素数却不增加。看起来右侧空间比左侧空间小。如何正确居中?

JFrame f = new JFrame("Checkers");
f.setDefaultCloSEOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(400,400);
f.setVisible(true);
JButton onePlayer=new JButton("1 Player");
onePlayer.setBounds(100,100,200,30);
add(onePlayer);
onePlayer.setVisible(true);
setLayout(null);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)