aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes transparent jbuttons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "transparent jbuttons" Watch "transparent jbuttons" New topic
Author

transparent jbuttons

Jim Henessey
Ranch Hand

Joined: Sep 13, 2003
Posts: 32
Hello,
I'm working on a calendar app with a background image in a JPanel. I would like to have the borders of the various days painted in with the day in the upper right corner of each day as a jbutton, allowing users to click on it and edit their schedule for that day. Is it possible to have a transparent jbutton - when I try the usual setopaque, I'm told this isn't allowed for this component. Is there an alternative way of creating a transparent jbutton than through this method?
Thanks.
VIJAY Yadlapati
Ranch Hand

Joined: Aug 04, 2003
Posts: 175
You have to create customised Button - a class extending JButton, overriding paint() method. In paint() method, you have to provide painting for the component.
Note: don't call super.paint() in paint() method implementation.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Actually, it's a lot simpler than that... just call these two methods on your JButton :


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Lee Barney
Ranch Hand

Joined: May 07, 2003
Posts: 37
A JLabel would also work if you add a mouseListener. I have done this. I can then controle the size of the component very well.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: transparent jbuttons