Back to other windows

0

I have the following:

    JButton btnSalir = new JButton("Volver");
    btnSalir.setBounds(469, 674, 89, 23);
    btnSalir.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {

            Administrador Admin = new Administrador();
            Admin.setVisible(true);

            ModificarEmpleados.this.dispose();
            setVisible(false);


        }
    });
    contentPane.add(btnSalir);

This works for me and returns to the administrator window, the issue is that I need it, if you open it from the administrator window, return to administrator, as it does, but if you open it from the operator window, go back to the operator without leaving to go to the administrator.

    
asked by Melannie Nichole 08.11.2017 в 02:17
source

1 answer

1

To go back you can close the window using the finalize() method. That way it does not matter in which window you are always going back to the previous one.

btnSalir.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent arg0) {

        finalize();

    }
});
    
answered by 08.11.2017 в 02:34