Creating a game in Javaswing and cant make the Jpanel switch to another

  Kiến thức lập trình

I am creating a project in Javaswing and am trying to get my project to switch from one Panel to another but when I try to switch the Panel will show up as blank

private void formMouseClicked(java.awt.event.MouseEvent evt) {
if (Pause.hitbox.contains(evt.getPoint())){
Settings settings = new Settings(this); //it calls the constructor of frmGame (line 16)
this.add(settings);
settings.setVisible(true);
settings.setSize(this.getWidth(), this.getHeight());
this.setVisible(false); //this hides our current menu (we don’t need both)

        System.out.println("settings clicked");
    }

Im lost lmk if theres anything you need

New contributor

Zunair Muhammad hekplayz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT