Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
JButtonテキストと同じサイズのテイクを作成することはできますか? デフォルトではJButton、テキストの周りに少量のパディング (水平と垂直の両方) があるためです。そのパディングを削除したいと思います。
JButton
ボタンの余白を でクリアしますsetMargin。
setMargin
境界線を削除すると、境界線が削除されるという副作用があります。余白のみをクリアしたい場合は、setMarginメソッドを使用して余白をすべてゼロに設定します。
button.setMargin(new Insets(0,0,0,0));
JButtonにはデフォルトで境界線があり、削除できます。
button.setBorder(null);
境界線を維持したい場合は、余白を減らします(ユージンの回答を参照)