I created a user interface that looks something like this:
https://i.stack.imgur.com/oBNSZ.jpg
+You can ignore the background pic. The issue is that the 2 JLabel's have white backgrounds. I've been working for a while using setOpaque() on the labels to false, the panel too, editing the setBackground(), and more. My goal is to have the background behind both JLabel's to be black and semi-transparent. Any suggestions?
The idea with this code is that whenever a UserInterface() object is created, the startScreen() can create a JPanel and return it to the constructor, and apply it to the JFrame. --Keep in mind this class is not complete and part of a larger program.
import javax.swing.*;
import java.awt.*;
public class UserInterface extends JFrame{
private final int WINDOW_WIDTH = 1250;
private final int WINDOW_HEIGHT = 750;
public UserInterface(){
super("idk");
setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
setLocationRelativeTo(null);
add(startScreen());
setVisible(true);
}//UserInterface
/*
public JPanel gameScreen(){
}//gameScreen
*/
public JPanel startScreen(){
JPanel backgroundPanel;
backgroundPanel = new JPanel(null);//using absolute positioning
//backgroundPanel.setBackground(new Color(15, 15, 15));
backgroundPanel.setOpaque(false);
JLabel title;
title = new JLabel("idk");
title.setOpaque(false);
//title.repaint();
title.setBackground(new Color(15, 15, 15));
title.setFont(new Font("Consolas", Font.PLAIN, 250));
title.setHorizontalAlignment(SwingConstants.CENTER);
title.setVerticalAlignment(SwingConstants.TOP);
title.setBounds(WINDOW_WIDTH / 4, WINDOW_HEIGHT / 20, (WINDOW_WIDTH / 4) * 2, WINDOW_WIDTH / 5);
JLabel trademark;
trademark = new JLabel("Eric Parsons");
trademark.setFont(new Font("Edwardian Script ITC", Font.PLAIN, 60));
trademark.setBounds(10, (WINDOW_HEIGHT / 20) * 17, 280, 80);
JButton begin;
int beginSizeX = 350;
int beginSizeY = 50;
begin = new JButton("Begin");
begin.setBounds((WINDOW_WIDTH / 2) - (beginSizeX / 2),
(WINDOW_HEIGHT / 2) - (beginSizeY / 2), beginSizeX, beginSizeY);
begin.setBackground(new Color(160, 160, 160));
begin.setFont(new Font("Consolas", Font.PLAIN, 25));
begin.setFocusable(false);
backgroundPanel.add(title);
backgroundPanel.add(begin);
backgroundPanel.add(trademark);
titlePageBackground.ScrollingBackground background = new titlePageBackground.ScrollingBackground();
background.setFocusable(true);
backgroundPanel.add(background);
return backgroundPanel;
}//startScreen
}//UserInterface
I feel the issue is the order where I add the objects, but I don't know where I've gone wrong. I appreciate all the comments and help!
__ Update: Changing setOpaquq() doesn't help issue for both panel and label