I'm using 2 pictures, one of these is the background of the screen and the other one is the background of a button. The image of the button is transparent in some parts. I'd like it to cover the background image on the transparent parts
It should look like this, but it doesn't. It looks like this.
Here is my code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class TryOut1 extends JFrame
{
public TryOut1()
{
screen();
buttonDoor();
setSize(1280,1024);
}
public void screen(){
setSize(1280,1024);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
setLayout(new BorderLayout());
setContentPane(new JLabel(new ImageIcon("Ziegel4.jpg")));
setLayout(new FlowLayout());
setSize(1280,1024);
}
public void buttonDoor(){
JButton b1 = new JButton(new ImageIcon("Tor2.png"));
b1.setEnabled(true);
b1.setVisible(true);
b1.setBackground(new Color( 0, 0, 0, 0) );
add(b1);
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
dispose();
}
});
}
public static void main(String args[])
{
new TryOut1();
}
}
How would I be able to make the transparent parts of the image actually transparent
Thank u for ur help in advance ^^