Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Change color and width of a JButton border, but keep rollover feedback

806562May 9 2011 — edited May 9 2011
I am using JButtons to display clickable thumbnails. The thumbnails are for images downloaded from the web. The code below is for the class ThumbnailButton, which extends JButton
    public ThumbnailButton(String title, String id, String url) throws MalformedURLException
    {
        setIcon(new ImageIcon(new URL(url)));
        setToolTipText(title);
        setActionCommand(id);
                
        setBackground(Color.WHITE);
        //setBorder(BorderFactory.createLineBorder(Color.ORANGE, LINE_BORDER_WIDTH));
        setMargin(new Insets(PADDING, PADDING, PADDING, PADDING));
    }
The commented line changes the button's border to a thicker orange color. However, when I do this, the visual feedback from rolling over the image with the mouse pointer disappears. Without the line, when the user rolls their mouse over the image, the border changes from a thin black to a thick blue. Also, when you hold the mouse button down over the image, the margins of the button turn blue.

Basically I would like to emulate the same effect but with Orange instead of blue. What is the simplest way to do this?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 6 2011
Added on May 9 2011
2 comments
676 views