I have a JButton with an image icon and I need to position the text. Is there a way to position the text of a JButton in a specific position instead of using CENTER,LEADING, TOP and so on?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Spanish: Puedes sobreescribir el método setText(String str).
Google Traductor English: You can overwrite the method setText (String str).
you can use set bounds method to set the postion of the text on the button
for more detail click here
I've never tried it on a JButton before, but maybe you can add a JLabel as a component on the button. Then you can use layout managers or Borders to position the label more appropriately.
Here are some example of adding a component to a JLabel with an Icon:
I doubt the JTExtPane example will work with a button because the text pane will intercept the mouse events and so you will not be able to click the button when you click on the text. So I would stick with the examples that add a label to the button.