File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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: 2092
    
    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: 2092
    
    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: 19544
    
  16

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: 4523
    
    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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get BasicArrowButton icon
 
Similar Threads
Creating Arrow Icon Help
Question about JOptionPane
Drop Down Menu Buttons
Get the icon from the JComboBox button
Problem with updating look and feel colors of swing components dynamically