Creer une application msn m aider a la terminer

massami123 Messages postés 6 Date d'inscription mercredi 17 mars 2010 Statut Membre Dernière intervention 2 juin 2010 - 17 mars 2010 à 23:42
massami123 Messages postés 6 Date d'inscription mercredi 17 mars 2010 Statut Membre Dernière intervention 2 juin 2010 - 18 mars 2010 à 17:11
bnsoir j ai une application qui consite a faire un msn j ai pu faire la connexion avec le serveur et meme apporté la liste de contact mais je suis bloqué apres je travail avec le language java et pour l interface c est swing
je travail avec le eclipse qui est dotté d une palette pour les interfaces si joint vous trous le code que j ai faitt et svpp quelqu1 pour m aider et pour ceux qui ont une iddé voila mon adresse email mayssam_mi@hotmail.com
et le code des trois classe est comme suit et la lib utiliser c est msnn .dans l attente d une reponse le plus vite possible je suis cerné avec le temps svp
import java.awt.BorderLayout;
import java.awt.Frame;

import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import java.awt.Dimension;
import javax.swing.JMenu;
import java.awt.Rectangle;
import javax.swing.JMenuItem;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;

import rath.msnm.MSNMessenger;
import javax.swing.JComboBox;

public class msninterface extends JFrame implements MsnConstantes{
private MSNMessenger msn;
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JMenuBar jJMenuBar = null;
private JMenu jMenu = null;
private JMenuItem jMenuItem = null;
private JMenu jMenu1 = null;
private JPanel jPanel = null;
private JLabel jLabel = null;
private JLabel jLabel1 = null;
private JTextField jTextField = null;
private JLabel jLabel2 = null;
private JPasswordField jPasswordField = null;
private JButton jButton = null;
private JLabel jLabel3 = null;
private JComboBox jComboBox1 ;
private JButton jButton1 = null;
private JLabel jLabel4 = null;
private JLabel jLabel5 = null;


/**
 * This is the default constructor
 */
public msninterface() {
super();
initialize();
}

/**
 * This method initializes this
 * 
 * @return void
 */
private void initialize() {
this.setSize(400, 800);
this.setJMenuBar(getJJMenuBar());
this.setContentPane(getJContentPane());
this.setTitle("JFrame");
}

/**
 * This method initializes jContentPane
 * 
 * @return javax.swing.JPanel
 */
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJPanel(), null);
}
return jContentPane;
}

/**
 * This method initializes jJMenuBar	
 * 	
 * @return javax.swing.JMenuBar	
 */
private JMenuBar getJJMenuBar() {
if (jJMenuBar == null) {
jJMenuBar = new JMenuBar();
jJMenuBar.add(getJMenu());
jMenu=new JMenu("Fichier");
jMenu.add(getJMenuItem());
jMenuItem=new JMenuItem("se deconnecter");
jMenu.add(jMenuItem);
jMenu.add(getJMenu1());
jMenu1=new JMenu("statut");
jMenu.add(jMenu1);
jJMenuBar.add(jMenu);

}
return jJMenuBar;
}

/**
 * This method initializes jMenu	
 * 	
 * @return javax.swing.JMenu	
 */
private JMenu getJMenu() {
if (jMenu == null) {
jMenu = new JMenu();
}
return jMenu;
}

/**
 * This method initializes jMenuItem	
 * 	
 * @return javax.swing.JMenuItem	
 */
private JMenuItem getJMenuItem() {
if (jMenuItem == null) {
jMenuItem = new JMenuItem();
}
return jMenuItem;
}

/**
 * This method initializes jMenu1	
 * 	
 * @return javax.swing.JMenu	
 */
private JMenu getJMenu1() {
if (jMenu1 == null) {
jMenu1 = new JMenu();
}
return jMenu1;
}

/**
 * This method initializes jPanel	
 * 	
 * @return javax.swing.JPanel	
 */
private JPanel getJPanel() {
if (jPanel == null) {
jLabel5 = new JLabel(new ImageIcon("C:/Users/HAJAR HANNAD/Desktop/image.jpg"));

jLabel5.setBounds(new Rectangle(151, 480, 45, 39));
jLabel5.setText("");
jLabel4 = new JLabel(new ImageIcon("C:/Users/HAJAR HANNAD/Pictures/Picture0222.jpg"));
jLabel4.setBounds(new Rectangle(123, 39, 102, 92));
jLabel4.setText("JLabel");
jLabel3 = new JLabel();
jLabel3.setBounds(new Rectangle(42, 382, 93, 16));
jLabel3.setText("       Statut");
jLabel2 = new JLabel();
jLabel2.setBounds(new Rectangle(37, 333, 93, 15));
jLabel2.setText("   mot de passe");
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(39, 295, 92, 16));
jLabel1.setText("        Email");
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(132, 179, 84, 25));
jLabel.setText("   Bienvenu!");
jPanel = new JPanel();
jPanel.setLayout(null);
jPanel.setBounds(new Rectangle(0, 3, 379, 705));
jPanel.add(jLabel, null);
jPanel.add(jLabel1, null);
jPanel.add(getJTextField(), null);
jPanel.add(jLabel2, null);
jPanel.add(getJPasswordField(), null);
jPanel.add(getJButton(), null);
jPanel.add(jLabel3, null);
jPanel.add(getJComboBox(), null);
jPanel.add(jLabel4, null);
jPanel.add(jLabel5, null);


}
return jPanel;
}

/**
 * This method initializes jTextField	
 * 	
 * @return javax.swing.JTextField	
 */
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new Rectangle(163, 294, 189, 20));
}
return jTextField;
}

/**
 * This method initializes jPasswordField	
 * 	
 * @return javax.swing.JPasswordField	
 */
private JPasswordField getJPasswordField() {
if (jPasswordField == null) {
jPasswordField = new JPasswordField();
jPasswordField.setBounds(new Rectangle(164, 331, 188, 20));
}
return jPasswordField;
}

/**
 * This method initializes jButton	
 * 	
 * @return javax.swing.JButton	
 */
/*private ActionListener alConnexion = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == jButton1) {
        	jPanel.setVisible(true);
        }
    }
};*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(new Rectangle(112, 534, 117, 26));
jButton.setText("Se connecter");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
//if(e.getSource()==jButton1){
//if(jTextField.getText()==null){
//JOptionPane.showMessageDialog(null,"Opérande manquant ou non valide!!");


//}else{
boolean error = test(); // on test la chaine
if(error){ // si erreur
JOptionPane.showMessageDialog(null,"email vide!!");// on affiche un msg
//jTextField.setText("");  // on vide la zone texte
}
else{
  msn = new MSNMessenger(jTextField.getText(),jPasswordField.getText());
                //status initial
                msn.setInitialStatus(MsnConstantes.tabPersoStatus[
                                     jComboBox1.
                                     getSelectedIndex()]);
               
                
                    msn.login();
                    
                    Contact ct=new Contact(msn);
                    ct.show();
                             

                    
}}}
);
}
return jButton;
}
public boolean test(){
boolean error = false;

 //on prend la chaine de la zone texte et on la met dans une chaine de caractère
if(jTextField.getText()==null)  // si la cchaine est vide
{error=true;} // on a une erreur

return error;
}

/**
 * This method initializes jComboBox	
 * 	
 * @return javax.swing.JComboBox	
 */
private JComboBox getJComboBox() {
if (jComboBox1 == null) {
jComboBox1 = new JComboBox(MsnConstantes.tabPersoStatus);

//jComboBox1.addItem(MsnConstantes.tabPersoStatus);
jComboBox1.setBounds(new Rectangle(165, 378, 103, 22));
}
return jComboBox1;
}

/**
 * This method initializes jButton1	
 * 	
 * @return javax.swing.JButton	
 */
 //  @jve:decl-index=0:visual-constraint="10,9"

}


import rath.msnm.UserStatus;

public interface MsnConstantes {

    

    //status msn messenger personnalisés
    static String[] tabPersoStatus = {"en ligne", "occupé", "absente", "au téléphone",
                                     "partie manger", "hors ligne"
                                     };

    //status msn messenger from rath
    static String[] tabRathStatus = {UserStatus.ONLINE, UserStatus.BUSY,
                                    UserStatus.BE_RIGHT_BACK,
                                    UserStatus.IDLE, UserStatus.ON_THE_PHONE,
                                    UserStatus.OFFLINE};

}

//import com.coded.jmsn.msg.Messagerie;
import java.text.Normalizer.Form;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JFrame;
import rath.msnm.BuddyList;
import rath.msnm.MSNMessenger;

public class Contact extends JFrame {
    
    /** Creates new form Contact */
    private MSNMessenger msn;
   // javax.swing.JButton b=new JButton();
   // private Messagerie msg;
    public Contact() {
        initComponents();
     
    }
    public Contact(MSNMessenger msnn)
    {
        initComponents();
        msn=msnn;
        
    }
    
    /** 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.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents()
    {

        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jScrollPane1.setViewportView(jList1);

        jMenu1.setText("Fichier");

        jMenuItem1.setText("Se déconnecter");
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Contacts");

        jMenuItem2.setText("ajouter contact");
        jMenu2.add(jMenuItem2);

        jMenuItem3.setText("bloquer contact");
        jMenu2.add(jMenuItem3);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(45, 45, 45)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 316, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(39, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(56, 56, 56)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        // TODO add your handling code here:
        Vector vcontact=new Vector();
        BuddyList list=msn.getBuddyGroup().getForwardList();
for(int i=0;i<list.size();i++)
{
vcontact.add(list.get(i));
}
                        jList1.setListData(vcontact);
                        //msn.getLoginName();
                        setTitle(msn.getLoginName()+" est "+msn.getInitialStatus());
        //msg.titre=msnconstantes.TITRE;
    }//GEN-LAST:event_formWindowOpened
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Contact().setVisible(true);
              
                
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JList jList1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables

}


p

aidez c est sur vous allez trouver qui vous aiderons

6 réponses

cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 130
18 mars 2010 à 07:45
Salut,

Ton code est tout simplement illisible ! Remercie le plugin d'eclipse qui produit un code de piètre qualité (bien qu'il soit tout de même de meilleure qualité que celui produit par netbeans, c'est déjà cà).

Ce n'est pas la première fois que je le fais remarquer : un plugin graphique donne l'illusion de gagner du temps, mais au final, il en fait perdre plus que si tu avais codé l'application à la main : en configurant comme il faut les modèles de code d'eclipse, tu arrives à coder la même interfaces en moins de 5 minutes en produisant un code optimisé et de qualité, alors que là... Les plugins graphiques de GUI devrait être utilisé UNIQUEMENT pour créer des maquettes à présenter aux client, mais surtout pas pour un programme qui est amené à être utilisé en production et qui doit être maintenu sur le moyen/long terme. Après, vous faites comme vous voulez : si vous voulez vous arracher les cheveux, c'est à vous de voir.

Comment veux-tu t'y repérer avec jMenuItem3, jLabel5, jPanel1, bon courage pour t'y retrouver, en tout cas, moi ca me donne aucune envie d'essayer de comprendre ton code ! Surtout que le plugins fait tout en absolut, et non en layout : quel intérêt ???
______________________________________

AVANT de poster votre message, veuillez lire, comprendre, et appliquer notre réglement
0
massami123 Messages postés 6 Date d'inscription mercredi 17 mars 2010 Statut Membre Dernière intervention 2 juin 2010
18 mars 2010 à 11:30
salut,
je suis tout a fait d accor avec toi mais pour faire un beau design et satisfaire notre prof j étai obligé de faire avec des pulgins pour un beau interface mais le probleme que j ai c est comment faire le chat l envoi des fichier donc les fonctionnalité de msn parceque je me suis juste arrivé à importer ma liste de contact donc c est possible de comprendre le code donc l acction du bouton et ma classe contact et ne pa faire attention au design svpppp


aidez c est sur vous allez trouver qui vous aiderons
0
massami123 Messages postés 6 Date d'inscription mercredi 17 mars 2010 Statut Membre Dernière intervention 2 juin 2010
18 mars 2010 à 11:32
je veux dire que les menu jusqu a mnt c est juste un design ça fonctionne pa mnt et c est a la fin que je vais le faire fonctionner

aidez c est sur vous allez trouver qui vous aiderons
0
Utilisateur anonyme
18 mars 2010 à 12:46
DARKSIDIOUS a raison, ton code est très peu commenté et les noms de variables ne sont pas très explicites. De plus, je ne suis pas d'accord avec toi, on peut faire de très belles interfaces sans "Sing GUI Forms" et équivalents. Quand j'étais en licence 3, j'avais eu à coder un clone en coquille vide de GAIM et je n'avais pas eu besoin de ce genre de plugin. Arrêtons l'hypocrisie, beaucoup de gens veulent éviter la complexité mais à la fin, quand ça ne marche pas comme attendu, si tu ne comprends pas comment marche Swing, tu es foutu.

S'il te plaît, si tu veux de l'aide, dis-nous au moins point par point ce qui ne marche pas et où tu bloques exactement.







TUER : http://tuer.sourceforge.net/tuer.jnlp

yeah! vive java
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 130
18 mars 2010 à 13:45
Salut,

Ca fait plaisir de voir qu'il y a quelqu'un d'autre qui pense comme moi concernant les plugins de création de GUI ;)
______________________________________

AVANT de poster votre message, veuillez lire, comprendre, et appliquer notre réglement
0
massami123 Messages postés 6 Date d'inscription mercredi 17 mars 2010 Statut Membre Dernière intervention 2 juin 2010
18 mars 2010 à 17:11
bonjour
je suis aussi d accord mais le probleme c est un travail qui est demandé le prof nous obligé de travailé avec les plugin le probleme et pas dans ce code tt ce que je vous ai ecrit est juste il y a pa des erreurs dedants tt marche bien la connexion avec le serveur microsoft et aussi l importation des listes de contactes,est ce vous pouvez m aider a le terminer chui bloqué a ce stade il faut faire le chat et les autre fonctionalité distingué entre les contact online et offline mais bon espérant que je trouve un soutient


aidez c est sur vous allez trouver qui vous aiderons
0
Rejoignez-nous