Autenticação com Interface Gráfica via NetBeans

5 respostas
Vitoriano

Olá,
Estou montando uma aplicação desktop com interação com banco de dados MySQL que esta na internet (mas estou usando banco local para teste). Sou leigo e estou começando a mexer com Java GUI, e não encontro material para tal. Vou passar o código da IDE se puderem me ajudar, e se tiverem algum material recente ou que funcione (de preferencia com NetBeans - ou tbm se sugerirem outro IDE tbm)…

Obrigado!

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Autenticacao.java
 *
 * Created on 03/06/2011, 15:38:58
 */
package br.com.ev.autentica;

/**
 *
 * @author Vitoriano Ferrero Martin Junior
 */
public class Autenticacao extends javax.swing.JFrame {

    /** Creates new form Autenticacao */
    public Autenticacao() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jPasswordField1 = new javax.swing.JPasswordField();
        jButton1 = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        jMenu3 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Usuário:");

        jLabel2.setText("Senha:");

        jTextField1.setText("jTextField1");

        jPasswordField1.setText("jPasswordField1");

        jButton1.setText("Entrar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jMenu1.setText("Arquivo");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Opções");
        jMenuBar1.add(jMenu2);

        jMenu3.setText("Ajuda");
        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton1)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)
                            .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(132, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>                        

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
    }                                        

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Autenticacao().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration                   
}

5 Respostas

danieldomingues86

Olá,

No seu método:

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }Voce deve implementar a logica para que seja validado a autenticação do usuario, e assim poder chamar a próxima tela.

Abraços
Daniel.

Vitoriano

Então Daniel, a “lógica” eu sei, não sei fazer isso em Java GUI =/
^^’ Tem alguma apostila, artigo ou material para me auxiliar?

Obrigado

danieldomingues86:
Olá,

No seu método:

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }Voce deve implementar a logica para que seja validado a autenticação do usuario, e assim poder chamar a próxima tela.

Abraços
Daniel.

Vitoriano

Alguém?
Preciso da lógica, e um modelo a seguir…

Ivan_Alves

Uma rápida pesquisa na internet você encontra várias coisas como por exemplo o próprio site do netbeans por exemplo

http://netbeans.org/kb/docs/java/quickstart-gui_pt_BR.html

pode ver essa aqui também

http://www.guj.com.br/content/articles/SwingNetbeans/SwingNetbeans.pdf

qualquer coisa procura swing com netbeans no gloogle

flw

Vitoriano

Ivan Alves:
Uma rápida pesquisa na internet você encontra várias coisas como por exemplo o próprio site do netbeans por exemplo

http://netbeans.org/kb/docs/java/quickstart-gui_pt_BR.html

pode ver essa aqui também

http://www.guj.com.br/content/articles/SwingNetbeans/SwingNetbeans.pdf

qualquer coisa procura swing com netbeans no gloogle

flw

Eu já fiz esse primeiro link, e assim que tiver um tempo vejo 2º…
A questão é que estou precisando implementar a logica… e O codigo para isso em java

Criado 6 de junho de 2011
Ultima resposta 13 de jul. de 2011
Respostas 5
Participantes 3