im making a program and i've no idea how to make this thing work: I have a mainFrame :
package itneizapenoitseg;
public class mainFrame extends JFrame {
    private dbconnection database = new dbconnection(); // DB connetion data (login , passw ..)
    private JDesktopPane desktop = new JDesktopPane(); // Need this to make Frame inside Frame
    public mainFrame() {
        super("");
        setLayout(null);
        setSize(850, 700);
        setLocation(500, 280);
        Login login = new Login(database);// I want to perform a login
        desktop.add(login);
        try {
            login.setSelected(true);
        }
        catch (Exception e) {
            // TODO: handle exception
        }
        setContentPane(desktop);
        /////////////////////////////////////////
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
    }
    public static void main(String [] args) {
        new mainFrame();
    }
}
The login class :
package itneizapenoitseg;
import... //
public class Login extends JInternalFrame {
    // User and password fields
    JTextField usernameForm = new JTextField(15);
    JPasswordField passwordForm = new JPasswordField(15);
    JButton login = new JButton("Login");
    public Login(dbconnection database) {
        super("Login", true, true, true, true);
        setSize(300, 200);
        // The login panel
        JPanel panel = new JPanel();
        panel.setLayout(null);
        JLabel username = new JLabel("username :");
        JLabel password = new JLabel("password :");
        // Position
        username.setBounds(70, 10, 80, 11);
        password.setBounds(70, 55, 80, 17);
        usernameForm.setBounds(70, 30, 150, 20);
        passwordForm.setBounds(70, 75, 150, 20);
        login.setBounds(105, 100, 80, 20);
        // Addings elements to display panel
        panel.add(usernameForm);
        panel.add(passwordForm);
        panel.add(login);
        panel.add(password);
        panel.add(username);
        getContentPane().add(panel);
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);// Doens't work
        setVisible(true);
        actionLogin(database);
    }
    // When pressing Login button...
    private void actionLogin(dbconnection database) {
        login.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //TODO Have to change to MySql query
                String usname = usernameForm.getText();
                String passw = new String(passwordForm.getPassword());
                // Checking credencial
                if(usname.equals("test") && passw.equals("1234")){
                    // Here i want to call a mainFrame funcion (createGUI)
                    dispose();Destroy this panel
                } else{
                    JOptionPane.showMessageDialog(null, "Username or password wrong!");
                    usernameForm.setText("");
                    passwordForm.setText("");
                    usernameForm.requestFocus();
                }
            }
        });
    }
}  
I want that when somebody successfully login, a mainFrame's function createGui is called or a way to notify the mainFrame. My intention is to make the mainFrame empty until sombody successfully login and next display it's content.
 
     
     
    