Is there any posibility of changing Icon image posintion in JButton?
This is how it looks now:
I want to move the icon more to the left.
I have tried to change the text alignment but it doesn't work as I want:
myButton.setHorizontalTextPosition(SwingConstants.RIGHT);
Have a look at JButton.setHorizontalAlignment(int align)
Sets the horizontal alignment of the icon and text. AbstractButton's default is SwingConstants.CENTER, but subclasses such as JCheckBox may use a different default.
you can set:
You can change the gap of the space between the icon and text with setIconTextGap(int)
. In addition, aligning the contents of the JButton
towards the left may help with setHorizontalAlignment(SwingConstants.LEFT)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With