Vérification de remplissage de champ

Fermé
am91 Messages postés 1 Date d'inscription jeudi 16 avril 2015 Statut Membre Dernière intervention 16 avril 2015 - 16 avril 2015 à 01:28
 Utilisateur anonyme - 24 avril 2015 à 09:09
svp je suis débutante en java je veux faire la vérification de remplissage de champ ??
voilà mon code
public Informationexpediteur() {
super();
initGUI();
}

private void initGUI() {
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
getContentPane().setLayout(null);
{
jPanel1 = new JPanel();
getContentPane().add(jPanel1);
jPanel1.setBounds(0, 0, 950, 526);
jPanel1.setBackground(new java.awt.Color(192,192,192));
jPanel1.setLayout(null);
{
jLabel1 = new JLabel();
jPanel1.add(jLabel1);
jLabel1.setText("Expediteur : ");
jLabel1.setBounds(12, 41, 117, 22);
jLabel1.setBorder(BorderFactory.createTitledBorder(""));
jLabel1.setFont(new java.awt.Font("Segoe UI",1,14));
}
{
jLabel2 = new JLabel();
jPanel1.add(jLabel2);
jLabel2.setText("Civilité de l'expediteur");
jLabel2.setBounds(47, 69, 161, 16);
}
{
jLabel3 = new JLabel();
jPanel1.add(jLabel3);
jLabel3.setText("Prenom de l'expediteur *");
jLabel3.setBounds(47, 91, 161, 16);
}
{
jLabel4 = new JLabel();
jPanel1.add(jLabel4);
jLabel4.setText("Nom de l'expediteur *");
jLabel4.setBounds(47, 113, 161, 16);
}
{
jLabel5 = new JLabel();
jPanel1.add(jLabel5);
jLabel5.setText("Date naissance de l'expediteur");
jLabel5.setBounds(47, 135, 193, 16);
}
{
jLabel6 = new JLabel();
jPanel1.add(jLabel6);
jLabel6.setText("Adresse *");
jLabel6.setBounds(47, 157, 82, 16);
}
{
ComboBoxModel jComboBox1Model =
new DefaultComboBoxModel(
new String[] { "M","Mme","Mlle" });
jComboBox1 = new JComboBox();
jPanel1.add(jComboBox1);
jComboBox1.setModel(jComboBox1Model);
jComboBox1.setBounds(269, 58, 67, 27);
jComboBox1.setBackground(new java.awt.Color(223,220,215));
}
{
jTextField1 = new JTextField();
jPanel1.add(jTextField1);
jTextField1.setBounds(269, 110, 125, 23);
}
{
jTextField2 = new JTextField();
jPanel1.add(jTextField2);
jTextField2.setBounds(269, 88, 125, 23);
}
{
jTextField3 = new JTextField();
jPanel1.add(jTextField3);
jTextField3.setBounds(269, 132, 125, 23);
}
{
jLabel7 = new JLabel();
jPanel1.add(jLabel7);
jLabel7.setText("Code postal *");
jLabel7.setBounds(47, 257, 98, 16);
}
{
jTextField4 = new JTextField();
jPanel1.add(jTextField4);
jTextField4.setBounds(269, 246, 123, 23);
}
{
jLabel8 = new JLabel();
jPanel1.add(jLabel8);
jLabel8.setText("Ville *");
jLabel8.setBounds(47, 279, 60, 16);
}
{
jTextField5 = new JTextField();
jPanel1.add(jTextField5);
jTextField5.setBounds(269, 269, 123, 24);
}
{
jLabel9 = new JLabel();
jPanel1.add(jLabel9);
jLabel9.setText("Type de piece d'identité");
jLabel9.setBounds(47, 301, 177, 16);
}


{
jRadioButton1 = new JRadioButton();
jPanel1.add(jRadioButton1);
jRadioButton1.setText("Carte d'identité");
jRadioButton1.setBounds(269, 313, 102, 20);
}
{
jRadioButton2 = new JRadioButton();
jPanel1.add(jRadioButton2);
jRadioButton2.setText("Passeport");
jRadioButton2.setBounds(269, 297, 79, 12);
}

{
group=new ButtonGroup();
group.add(jRadioButton1);
jRadioButton1.setBackground(new java.awt.Color(192,192,192));
group.add(jRadioButton2);
jRadioButton2.setBackground(new java.awt.Color(192,192,192));
}

{
jLabel10 = new JLabel();
jPanel1.add(jLabel10);
jLabel10.setText("Numero de piéce d'identité *");
jLabel10.setBounds(47, 343, 204, 16);
}
{
jTextField6 = new JTextField();
jPanel1.add(jTextField6);
jTextField6.setBounds(269, 339, 123, 26);
}
{
jLabel11 = new JLabel();
jPanel1.add(jLabel11);
jLabel11.setText("Numéro de telephone de l'expediteur *");
jLabel11.setBounds(47, 371, 222, 16);
}
{
jTextField7 = new JTextField();
jPanel1.add(jTextField7);
jTextField7.setBounds(269, 365, 123, 22);
}

{
jButton1 = new JButton();
jPanel1.add(jButton1);
jButton1.setText("MONTANT A TRANSFERER");
jButton1.setBackground(new Color(153,0,0));
jButton1.setBounds(7, 13, 222, 23);
jButton1.setForeground(new java.awt.Color(255,255,255));
jButton1.setFont(new java.awt.Font("Segoe UI",1,14));
jButton1.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub

}
});
}
{
jButton2 = new JButton();
jPanel1.add(jButton2);
jButton2.setText("INFORMATIONS EXPEDITEUR");
jButton2.setBackground(new Color(153, 0, 0));
jButton2.setBounds(240, 13, 230, 23);
jButton2.setFont(new java.awt.Font("Segoe UI",1,14));
jButton2.setForeground(new java.awt.Color(255,255,255));
jButton2.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub

}
});
}
{
jButton3 = new JButton();
jPanel1.add(jButton3);
jButton3.setText("INFORMATIONS DESTINATAIRE");
jButton3.setBackground(new Color(242,242,242));
jButton3.setEnabled(false);
jButton3.setBounds(481, 13, 223, 23);
jButton3.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub

}
});
}
{
jButton4 = new JButton();
jPanel1.add(jButton4);
jButton4.setText("VERIFICATION PAIEMENT");
jButton4.setBackground(new Color(242,242,242));
jButton4.setEnabled(false);
jButton4.setBounds(715, 13, 214, 23);
jButton4.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub

}
});
}
{
jScrollPane1 = new JScrollPane();
jPanel1.add(jScrollPane1);
jScrollPane1.setBounds(269, 161, 212, 79);
{
jTextArea1 = new JTextArea();
jScrollPane1.setViewportView(jTextArea1);
jTextArea1.setBounds(511, 166, 200, 91);
}
}
{
btnDate = new JDateChooser();
jPanel1.add(btnDate);
btnDate.setBounds(400, 132, 159, 23);

}
{
jButton7 = new JButton();
jPanel1.add(jButton7);
jButton7.setText("Valider");
jButton7.setIcon(new ImageIcon(getClass().getClassLoader().getResource("check.png")));
jButton7.setBounds(673, 365, 135, 37);
jButton7.setFont(new java.awt.Font("Segoe UI",1,12));
jButton7.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent arg0) {
Informationsdestinataire windowInfodest = new Informationsdestinataire();
windowInfodest.setVisible(true);
windowInfodest.setLocationRelativeTo(null);
dispose();


}
});
}
{
jButton5 = new JButton();
jPanel1.add(jButton5);
jButton5.setText("Etape précédente");
jButton5.setIcon(new ImageIcon(getClass().getClassLoader().getResource("back.png")));
jButton5.setBounds(30, 396, 178, 36);
jButton5.setFont(new java.awt.Font("Segoe UI",1,12));
jButton5.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent arg0) {
Montantdutransfert windowmontant = new Montantdutransfert();
windowmontant.setVisible(true);
windowmontant.setLocationRelativeTo(null);
dispose();



}
});
}

}
pack();
this.setSize(966, 564);
} catch (Exception e) {
//add your error handling code here
e.printStackTrace();
}
}

}

2 réponses

VlkPr3s Messages postés 235 Date d'inscription vendredi 30 mai 2014 Statut Membre Dernière intervention 27 juin 2016 130
16 avril 2015 à 09:17
Personnellement pour une débutante je trouve qu'utilisé java est un peu plus compliqué que PHP.

En php tu peux vérifié les champs de ton formulaire via la méthode !empty ou empty ou dépend si tu veux voir s'il y a qque chose dedans ou non.
0
VlkPr3s Messages postés 235 Date d'inscription vendredi 30 mai 2014 Statut Membre Dernière intervention 27 juin 2016 130
16 avril 2015 à 09:37
Sinon si tu veux rester sur du javascript je ne vais pas recopier ce qu'un autre à déjà fait ici va voir sur ce lien

https://forums.commentcamarche.net/forum/affich-2262176-javascript-verifier-si-un-champ-est-vide
0
Utilisateur anonyme
24 avril 2015 à 09:09
Salut, tu peux simplement faire :

if (label.equalsIngnoreCase("") {
    // Message d'avertissement champs vide
    return;
}
0