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
|
Conexion c=new Conexion();
c.Qouery("jdbc:mysql://localhost/mabase", "root","","SELECT * FROM test");
try{
String []titre={"id","nom", "prenom", "sexe", "password","login"};
System.out.println();
/** Etape 5: utilisation du résultat */
String [][]data=new String[c.getVariable1()][6];
while( c.getResultat1().next() ) {
for(int j = 0; j <2 ; j++){
for(int i=0;i<c.getVariable1();i++){
data[j][i]=c.getResultat1().getString(i+1);
}}
JTable tableau = new JTable(data,titre);
tableau.setBackground(Color.decode("#FCE1AB"));
JScrollPane scp=new JScrollPane(tableau); // JScrollpane barre de defilement
scp.setBackground(Color.decode("#FCE1AB"));
JFrame jf=new JFrame();
jf.setSize(500,400);
jf.setBackground(Color.decode("#FCE1AB"));
Container cont= jf.getContentPane();
cont.setLayout(new FlowLayout());
cont.add(scp); |
Partager