Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JButtons  RSS feed

colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm trying to put some images on JButtons, eg

I've discovered that the size of the image that should fit perfectly into the JButton, should be 4 pixels less in width, and 4 pixels less in height.
The JButton above is 62 by 25, and an image 58 by 21 fits perfectly inside it.

But when I used a JButton that was 25 by 25, and I tried to put an image that was 21 by 21 inside it, the image was displayed 1 pixel right, leaving a vertical gray line to the left of the image inside the JButton, and the far right edge of image (1 pixel wide) could not be seen.

I was wondering if there was any convention of image sizes in relation to the JButtons they fit inside.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!