bonjour,
j'ai un problem d'affichjafe pour une JTable:en effet, le header du jtable n'apparut pas meme que j'ai fais l'instanciation du JTable avec une matrice de donne et un tableau String comme header ,ce dernier ne s'affiche pas:
qq peux m'aider.
voila les deux classe:
la premierepermet de lire les donnes depuis la base et crerr l'objet JTable:
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
package aymen;
 
import javax.sql.*;
import javax.swing.JTable;
 
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
import java.sql.*;
 
public class listeClient {
 
	MysqlDataSource bd =new MysqlDataSource(); 
	Connection con;
	Statement stat;
    ResultSet res;
    JTable tableau ;
	Object[][] matrice=new Object[1][10];
	String[] liste={"id", "nom", "prenom", "CIN", "raison social", "mf","rc","tel", "fax"};
 
	public listeClient() {
		bd.setUrl("jdbc:mysql://localhost:3306/facturation");
		bd.setDatabaseName("facturation");
		bd.setUser("root");
		bd.setPassword("");
		try {
			con= bd.getConnection();
			stat=con.createStatement();
			res=stat.executeQuery("select * from client");
			while(res.next()){	
			matrice[0][0]=Integer.toString(res.getInt("id_client"));	
			matrice[0][1]=res.getString("nom");
			matrice[0][2]=res.getString("prenom");
			matrice[0][3]=res.getString("CIN");
			matrice[0][4]=res.getString("raison social");
 
			}
 
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		tableau=new JTable(matrice,liste);
		System.out.println(liste[1]);
	}
public static void main(String[] args){
 
	listeClient c=new listeClient();
 
}
}
le deuxieme contien des onglets:le premier va afficher le composant Jtabkle:
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
package aymen;
 
import java.awt.*;
import javax.swing.*;
 
public class MainFrame extends JFrame{
 
JTabbedPane Onglet=new JTabbedPane();
JPanel Pclient=new JPanel();
JPanel Pfacture=new JPanel();
JPanel Pcontrat=new JPanel();
 
 
	public MainFrame() {
		this.setTitle("MainFrame");
        this.setSize(300, 300);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setLocationRelativeTo(null);  
        this.setVisible(true);
        this.setLayout(new BorderLayout());
        this.getContentPane().add(Onglet, BorderLayout.CENTER);
 
        //ajout des onglets au JTabbedPane
	    Onglet.addTab("client", Pclient);
	    Onglet.addTab("contrat", Pcontrat);
	    Onglet.addTab("facture", Pfacture);
 
	    //ajout des JPanels BorderLayout pour tout les onglets
	    Pclient.setLayout(new BorderLayout());
	    Pcontrat.setLayout(new BorderLayout());
	    Pfacture.setLayout(new BorderLayout());
 
	    Pclient.add(new listeClient().tableau ,BorderLayout.CENTER);
	}
 
	/**
         * @param args
         */
	public static void main(String[] args) {
		MainFrame fenetre=new MainFrame();
 
	}
 
}
merci bien