• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get BasicArrowButton icon

 
Bobby Anderson
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to get the icon not the actual button object that the BasicArrowButton uses.

I tried


But that is returning me null. I would like to use this same icon for another object but I have no idea how to get a hold of it.
 
Rob Camick
Ranch Hand
Posts: 2619
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Create a button
2) Use the Screen Image class to get an image of the button
3) Create an ImageIcon from the Image.
 
Bobby Anderson
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tricky, Tricky. There has got to be an easier way. BasicArrowButton gets/draws that button can't I do the same?
 
Rob Camick
Ranch Hand
Posts: 2619
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Billy Newman wrote:There has got to be an easier way.


Why? Do you understand how painting in Swing works? You have already stated that there is no icon for you to use. Therefore the component must use custom painting to draw the arrow.

Billy Newman wrote:BasicArrowButton gets/draws that button can't I do the same?


Sure, just copy the painting code from the BasicArrowButton paint() method.

I'll let you decide which is easier.
 
Rob Spoor
Sheriff
Pie
Posts: 20671
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a BufferedImage, get its Graphics2D environment, and draw on that:
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No need to paint the entire button to the BufferedImage, you can paint just the arrow using paintTriangle(...)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic