Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

creating buttons with graphics

 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there, can anyone recommend me how to create a button with an arrow instead of text with the word UP, or DOWN
 
Anand Loni
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u can use ImageIcons for JButtons...
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you asking how to create the button, or how to create the icon/image?
 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to create the image and assign it to the button,
thanks
 
Anand Loni
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, here is small code that creates ImageIcon and shows it with text on JButton...


ImageIcon image = new ImageIcon("images/image1.gif");
JButton button = new JButton("Image with Text", image);

the parameter to constructor of ImageIcon is path of gif image and button
will have text "Image with Text" and gif image.
 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cheers thats helpful
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic