JButton btnNewButton = new JButton("Register Student");
btnNewButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
RegisterStudent panel_1 = new RegisterStudent();
panel_1.setVisible(true);
}
});
btnNewButton.setBounds(0, 162, 167, 37);
panel.add(btnNewButton);
Is there a way, that IF one specific window is open already, it cant be opened once again?
Because, i don’t want the user to click on a button several times, causing several windows to be opened with the same content?
Create the panel_1 variable outside of the mouse listener block and initialize it to null. When the mouse is clicked, check if panel_1 is null, and if it is, create it.