Bonjour, je suis débutant en java swing et j'aimerais faire une interface pour une application qui gère un répertoire téléphonique.
Voici, pour l'instant le code de ma classe Contact :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
public class Contact {
 
	private String nom;
	private String numero;
 
	public Contact(String n, String num){
		this.nom=n;
		this.numero=num;
	}
 
	public String getNom(){
		return nom;
	}
 
	public String getNumero(){
		return numero;
	}
}
et voici le code de ma classe Repertoire pour l'instant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
 
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;
 
 
public class Repertoire extends JFrame{
 
	private ArrayList<Contact> liste;
	private int tailleMax;
 
	public Repertoire(){
		liste = new ArrayList<Contact>();
		tailleMax = 500;
		init();
	}
 
	public boolean addContact(Contact c){
		if (liste.size()<tailleMax){
			liste.add(c);
			return true;
		}else
			return false;
	}
 
	public boolean removeContact(Contact c){
		if (liste.size()<=0)
			return false;
		else{
			liste.remove(c);
			return true;
		}
	}
 
	public ArrayList<Contact> getNumero(String nom){
		ArrayList<Contact> res = new ArrayList<Contact>();
		for (Contact c : liste){
			if (c.getNom().toLowerCase().equals(nom.toLowerCase()))
				res.add(c);
		}
		return res;
	}
 
	public void init(){
		setTitle("Repertoire");
	    setSize(680, 420);
	    setResizable(false);
	    setLocationRelativeTo(null);
	    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
	    setVisible(true);
 
	    JPanel pan = new JPanel();
	    pan.setLayout(new GridBagLayout());
 
		JLabel texte = new JLabel("Recherche :");
		JTextField recherche = new JTextField();
		JButton valider = new JButton("Rechercher");
		JTable listeContacts = new JTable(2, liste.size());
		JButton ajouter = new JButton("ajouter");
		JButton supprimer = new JButton("Supprimer"); 
 
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.gridx = 1;
		gbc.gridy = 1;
		gbc.gridwidth = 1;
		gbc.gridheight = 1;	
		pan.add(texte, gbc);
 
	}
 
 
	public static void main(String[] args) {
		Repertoire rep = new Repertoire();
	}
}
J'ai voulu faire une essaie et je ne comprend pas pourquoi mon JLabel texte ne s'affiche pas dans ma fenêtre . Pouvez-vous me dire pourquoi ?
Merci d'avance.