How to open JInternalFrame window after login?

4

I'm new to desktop java and am doing a program with swing , and would like to know how to JInternalFrame open after login is done, follow the code for analysis.

  if(usuarioText.getText().equals(objConexao.rs.getString("nome"))
                && senhaText.getText().equals(objConexao.rs.getString("senha"))){


 //CadastroForm é um JInternalFrame

            CadastroForm form = new CadastroForm();  
            form.setVisible(true);  
            dispose();  



        }else{
            JOptionPane.showMessageDialog(null, "usuário invalido");
        }
    
asked by anonymous 13.12.2015 / 16:00

1 answer

3

The dispose method is making the frame invisible shortly after making it visible.

Unless it is for another frame, I would not know it with just that code.

But to open after login return true, an example follows

    JFrame jFrame = new JFrame();

    if (foiAutenticado()) {
        JInternalFrame jInternalFrame = new JInternalFrame();
        jInternalFrame.setVisible(true);
        jFrame.add(jInternalFrame);
        try {
            jInternalFrame.setSelected(true); //indica o fóco nesse JInternalFrame
        } catch (PropertyVetoException e) {
            e.printStackTrace();
        }
    } else {
        JOptionPane.showMessageDialog(null, "Usuário invalido");
    }

Of course, this JFrame I just passed is just for demonstration, make use of whatever JFrame you are in.

More examples and explanations on this link link

link

    
13.12.2015 / 16:56