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!

Transparent JButton

843805Nov 29 2006 — edited Dec 1 2006
Hi,

I am trying to create a JButton with a semi-transparent background. I created my own subclass, and overrode the paintComponent() method like this:
	public void paintComponent(Graphics g)
	{
		g.setColor(getBackground());
		g.fillRect(0, 0, getWidth(), getHeight());
		
		super.paintComponent(g);
	}
I am setting the color of it to white, with an alpha value of 100, but the background is behaving very oddly. What am I doing wrong? Thanks ahead of time.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 29 2006
Added on Nov 29 2006
10 comments
461 views