How to open Jinternalframe window after login?

Asked

Viewed 279 times

4

I am new in java for desktop and am making a program with swing, and would like to know how to make a 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");
        }

1 answer

3

The Dispose method is making the frame invisible right after making the same visible.

Unless it’s for another frame, I wouldn’t know with just that code.

But to open after login returns true, here is an example

    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 passed is only for demo, make use of whatever is in the application.

More examples and explanations at this link https://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html

https://docs.oracle.com/javase/7/docs/api/javax/swing/JInternalFrame.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.