JFrame by repeatedly opening twice

1

I'm new to programming for desktop, well, I'm doing a program in java using swing and sqlite database, I already did some things work, but after login the jframe that should open a single opens twice, how to fix this?

Follow the coidigo

 private void entrar() {

    String sql = "select * from login where usuario = ? and senha = ?";

    try {
        conn = conexao.ConnectionDB();         

        pst = conn.prepareStatement(sql);
        pst.setString(1, nomeUser.getText());
        pst.setString(2, senhaUser.getText());

        rs = pst.executeQuery();

        if (rs.next()) {

           new TelaPrincipal().setVisible(true);
           this.dispose();

        } else {
            JOptionPane.showMessageDialog(null, "Login inexistente");
        }

    } catch (Exception e) {

        JOptionPane.showMessageDialog(null, e);

    }

}
    
asked by anonymous 31.12.2015 / 03:26

1 answer

1

Hello, I was able to solve the problem, it was really my mistake, I happened to put the KeyPressed event and the actionPerformade with the method, but in some way, even when I clicked with the mouse, KeyPressed activated, basically KeyPressed and worked thank you.

    
31.12.2015 / 13:46