I currently have a function which sets the background and have 1 button. The button is a PNG file and is transparent, I have done all the setOpaque stuff but the button still have a white background behind it. If anyone could help will be greatly appreciated! :)
I have attached my function below:
public JPanel createContentPane() throws IOException{
//Full back pane
JPanel fullGUI = new JPanel();
fullGUI.setLayout(null);
//background pane
JPanel backgroundPane = new JPanel() {
BufferedImage image = ImageIO.read(new File("UI/back2.jpg"));
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(image, 0, 0, 1200, 750, this);
}
};
backgroundPane.setLayout(null);
backgroundPane.setLocation(0,0);
backgroundPane.setSize(1200,750);
fullGUI.add(backgroundPane);
//button pane
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(null);
buttonPanel.setLocation(0, 250);
buttonPanel.setSize(1200, 500);
fullGUI.add(buttonPanel);
JButton playButton = new JButton(new ImageIcon(("UI/play.png")));
playButton.setLocation(399,47);
playButton.setSize(405,308);
playButton.setOpaque(false);
playButton.setContentAreaFilled(false);
playButton.setBorderPainted(false);
playButton.setFocusPainted(false);
buttonPanel.add(playButton);
fullGUI.setOpaque(true);
return fullGUI;
}