[Ajuda] Client Twitter

1 resposta
J

Ae povo, tudo bom?

Estou criando um Client Twitter para um trabalho da faculdade. Mas não estou conseguindo fazê-lo funcionar, mesmo não tendo nenhum erro.

Podem me dar uma ajudinha por favor? Segue o código da tela de Login:

import Twitter.Principal;
import javax.swing.JOptionPane;
import javax.xml.ws.Action;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.User;

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

/**
 *
 * @author Juliano
 */
public class Login extends javax.swing.JFrame {

    /**
     * Creates new form Login
     */
    public Login() {
        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")
   

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        
        java.awt.EventQueue.invokeLater(new Runnable() {
           
            public void run() {
                java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Login l = new Login();
                l.setLocationRelativeTo(null);
                l.setVisible(true);
            }
        });
            }
        });
    }
    public String pegaSenha() {
        char[] senha = jPF_Senha.getPassword();
        String str = "";
        for (int i = 0; i < senha.length; i++) {
            str += senha[i];
        }
        return str;
    }

    @Action
    public void EfetuarLogin() {
        String usu = jTF_Usuario.getText();
        String senha = pegaSenha();

        try {
            Twitter t = new TwitterFactory().getInstance(usu, senha);
            User u = t.verifyCredentials();

            Principal p = new Principal(t,u);
            p.setLocationRelativeTo(null);
            p.setVisible(true);

            this.dispose();
        } catch (TwitterException e) {
            if (e.getStatusCode() == 401) {
                JOptionPane.showMessageDialog(this, "Usuário e/ou senha inválidos!");
            }
        }
    }
    // Variables declaration - do not modify
    private javax.swing.JButton jButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPasswordField jPF_Senha;
    private javax.swing.JTextField jTF_Usuario;
    // End of variables declaration
}

Segue a foto da tela de Login tbm:

[img]http://img848.imageshack.us/img848/2056/logina.jpg[/img]

1 Resposta

J

@Edit: Eu estou chamando o EfetuarLogin pelo Action do Button, mas fica caindo direto no Exception. Mesmo se o usuário e a senha estiverem corretos, o programa fala que estão incorretos.

Criado 29 de maio de 2012
Ultima resposta 29 de mai. de 2012
Respostas 1
Participantes 1