I have .jpg images in my buttons. I also would like to put some text on top of the images. I use the following syntax for that:
JButton btn = new JButton(label,icon);
But I do not see text in the buttons (only image). What am I doing wrong?
I have no idea why you are not seeing the text and icon. By default the text should be painted to the right of the icon.
To display the text on top of the icon you use:
JButton button = new JButton(...);
button.setHorizontalTextPosition(JButton.CENTER);
button.setVerticalTextPosition(JButton.CENTER);