This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi ! I have the follow problem.I have a button with a icon(gif) and no text, I set the icon with : button.setIcon(....).The icon size is 16,16 but my button is a little bit bigger that my icon.
What I need a "small" button - with the same size with its icon.
A solution is to use setPreferredSize method on my button(the pref. size is the icon size) but I not so "happy" with this. The logic behind this is : if the button content(picure and/or text) size is smaller than the preffered size than the last one(pref. size) is used, the button takes its icon size only if the icon is bigger that its preffered size.
You need to use setMargin(Insets). You will need to create an Insets object with values of like 1 or 0 for the amount of the inset so that your border is small or nill. I had to do this for JToolBar menus because, as you have found out, the margins are just too large.