aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Get BasicArrowButton icon Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Get BasicArrowButton icon" Watch "Get BasicArrowButton icon" New topic
Author

Get BasicArrowButton icon

Bobby Anderson
Ranch Hand

Joined: Oct 28, 2008
Posts: 114
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

Joined: Jun 13, 2009
Posts: 2200
    
    7
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

Joined: Oct 28, 2008
Posts: 114
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

Joined: Jun 13, 2009
Posts: 2200
    
    7
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

Joined: Oct 27, 2005
Posts: 19719
    
  20

Create a BufferedImage, get its Graphics2D environment, and draw on that:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

No need to paint the entire button to the BufferedImage, you can paint just the arrow using paintTriangle(...)


luck, db
There are no new questions, but there may be new answers.
 
Don't get me started about those stupid light bulbs.
 
subject: Get BasicArrowButton icon