Whenever I hover the mouse over a JButton with the setBackground method set to a new color with the alpha set to 10 it gets darker. The problem is when I take the mouse off of the button it still stays just as dark as if i were hovering over the button. On top of that when I hover over the button again it makes the button even darker.
I'm trying to make the button stay translucent so I can see the panel in the background.
import java.awt.*;
import javax.swing.*;
public class Test
{
private JFrame f;
private JPanel p;
private JButton b;
public Test()
{
f = new JFrame("Test");
f.setSize(400, 200);
p = new JPanel();
p.setLayout(new GridLayout(1, 1));
b = new JButton();
b.setBackground(new Color(255, 0, 0, 10));
p.add(b);
f.add(p);
}
public static void main(String args[])
{
Test t = new Test();
t.f.setVisible(true);
}
}
What I want is to create a translucent button so I can see the panel in the background.