Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

setting an image as a label for a button  RSS feed

 
meera sood
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everyone,
can anybody please help me out with this. I need to set the label of an AWT button to an image. Is there some way to do it or does the label have to be restricted to a String.
thanx
Meera
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Meera,
Unfortunately the AWT label is limited to text only. The API has the final word:

A Label object is a component for placing text in a container. A label displays a single line of read-only text. The text can be changed by the application, but a user cannot edit it directly.

Regards,
Manfred.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course... you could extend the regular AWT button with a setImage( Image ) method, and paint that Image on the Button in it's paint() method...

-Nate
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!