2

This is my code to set the label on the bottom of the button Icon.

m_button.setIcon(large);
m_button.setLabel(m_button.getName());
m_button.setVerticalTextPosition(m_button.BOTTOM);

m_button.setMargin(BUTTON_INSETS);
m_button.setSize(BUTTON_SIZE);
m_button.setSize(20, 20);

But the result is the below one.

enter image description here

How can I make it on the bottom of the icon? As this: enter image description here

Sajeev
  • 783
  • 3
  • 14
  • 46

1 Answers1

3

Set both horizontal and vertical text positions:

JButton button = new JButton("Test", icon);
button.setHorizontalTextPosition(SwingConstants.CENTER);
button.setVerticalTextPosition(SwingConstants.BOTTOM);
PA001
  • 451
  • 3
  • 12