Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JButtion ImageIcon problems  RSS feed

 
John Ironmonger
Greenhorn
Posts: 8
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, first of all i'm pretty new so my apologies if i'm not doing something right.

So, I created 3 button's to be overlayed onto my JButtons, which are exactly 400x35 width/height (here),and they appear to be fine when I have

uncommented, yet when I let the the standard swing button appear you can clearly tell that they have been cutoff (here) and then I can tell through Photoshop that java's actually cut the image off by seven pixels (here). That's the first problem, the second one being that there appears to be a stray pixel after each button which I assume is at the edge of the button image that java has cutoff (here). Any ideas ?

Here's my full code incase it's needed :



Any ideas as to why it's acting up would be greatly appreciated. Thank you in advance !
 
Rob Camick
Ranch Hand
Posts: 2756
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Don't set the preferred size. Each button will determine its own preferred size based on the properties of the button (icon, text border...).
 
John Ironmonger
Greenhorn
Posts: 8
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:

Don't set the preferred size. Each button will determine its own preferred size based on the properties of the button (icon, text border...).


After I deleted those lines the text of the button shifted to the right, so I just made sure the buttons had no text and that fixed both the dimension and the stray pixel problem. Again, thank you so much!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!