How do I position text in the middle of an Icon (loaded from a GIF) in a JButton?
Let's say that your Gif file filename is
in the String variable myGifFile.
Here is the code:
JButton button = new JButton();
// Here you tell the button to center the text in the horizontal direction
// The text position is relative to the icon. Normally it's RIGHT
// Here you tell the button to center the text in the vertical direction
// (Default is CENTER, so this isn't really necessary)
button.setText("My centered text!");