0

I am trying to draw mainPanel on top of the background image I set up so that you can still see the image even when the panel is up. setOpaque does not seem to be working. also I will be switching between panels all in the Galaga super class so I would like all the panels to act the same way.

public class Galaga extends JFrame {
    private static final long serialVersionUID = 1L;

    private JPanel mainPanel;//main menu with top-level button
    private JPanel optionsPanel; //has option buttons and detail
    private JPanel highScorePanel; //shows high scores
    public BufferedImage image;

    public Galaga(String t) {
        super(t);

        JLayeredPane pane = this.getLayeredPane();
        File img = new File("images/Spacebackground.png");
        try {
            image = ImageIO.read(img);
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }

        mainPanel = new MainPanel(this);
        mainPanel.setOpaque(false);
        mainPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        add(mainPanel, BorderLayout.CENTER);//adds main panel
        }//ends Galaga function

0 Answers0