是否可以更改 JButton 中的图标图像位置?
现在是这样的:
我想把图标移到更左边。
我已尝试更改文本对齐方式,但它无法正常工作:
myButton.setHorizontalTextPosition(SwingConstants.RIGHT);
最佳答案
看看 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.
你可以设置:
- SwingConstants.RIGHT
- SwingConstants.LEFT
- SwingConstants.CENTER
- SwingConstants.LEADING
- SwingConstants.TRAILING
关于java - JButton 中的图标位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31640205/