Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Text on the JButton Image  RSS feed

 
Vani Shastri
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a JButton and i have set a new Icon (new image) to it.
How do i set text on the image ?

jbutton.setIcon(new ImageIcon("C:/Image.GIF"));

Thanks
 
Terry Ong
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try JButton's properties, horizontalTextPosition, and verticalTextPosition.
does not have lots of options though.

to customise more, you'll need to subclass JButton and override the paint method.

See the java tutorial on custom painting for more info,
http://java.sun.com/docs/books/tutorial/uiswing/painting/index.html
 
Pavan Kumar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep.
Hope this helps


[ January 05, 2007: Message edited by: Pavan Kumar Mankala ]
[ January 05, 2007: Message edited by: Pavan Kumar Mankala ]
 
Vani Shastri
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Pavan. That was exactly what i was looking for.
Have a nice day .
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!