我希望在我的应用程序中有两个透明背景的按钮,我已经“几乎”完成了。
这是我所做的:
这是我目前的视觉效果:
很好,这正是我想要的。但当我将鼠标移到这两个按钮上时,会发生以下情况:
首先,背景逐渐变得不透明,每次鼠标移动时都会变得更少,然后我们可以看到两个按钮的文本混在一起。
非常感谢您的回答。
这是我所做的:
public class PanelMenu extends JPanel{
//VARIABLES
private JButton buttonFightSimulator, buttonMatchUp;
//CONSTRUCTORS
public PanelMenu ()
{
this.setBounds(0,0,240,768);
this.setLayout(new FlowLayout(0, 0, 0));
//BUTTON CREATION
buttonFightSimulator = new JButton("FIGHT SIMULATOR");
buttonMatchUp = new JButton("MATCH UP");
buttonFightSimulator.setBackground(new Color(255,255,255,128));
buttonFightSimulator.setFocusPainted(false);
buttonFightSimulator.setBorderPainted(false);
buttonFightSimulator.setPreferredSize(new Dimension(240,60));
buttonMatchUp.setBackground(new Color(255,255,255,128));
buttonMatchUp.setFocusPainted(false);
buttonMatchUp.setBorderPainted(false);
buttonMatchUp.setPreferredSize(new Dimension(240,60));
add(buttonFightSimulator);
add(buttonMatchUp);
this.setBackground(new Color(0,0,0,90));
}
这是我目前的视觉效果:
![enter image description here](https://istack.dev59.com/Ix15I.webp)
![enter image description here](https://istack.dev59.com/ak5He.webp)
非常感谢您的回答。