A voir également:
- Tableau de string java
- Waptrick jeux java itel - Forum Jeux vidéo
- Tableau croisé dynamique - Guide
- Waptrick java football - Télécharger - Jeux vidéo
- Jeux java itel football - Télécharger - Jeux vidéo
- Tableau ascii - Guide
4 réponses
aainfo
Messages postés
80
Date d'inscription
jeudi 28 février 2008
Statut
Membre
Dernière intervention
30 juillet 2008
13
17 mars 2008 à 22:34
17 mars 2008 à 22:34
salut.....................
j'éspére que c'est ça ton bonheur.................
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import javax. swing.event.TableModelListener;
import javax.swing.event.TableModelEvent;
import javax.swing.*;
import java.sql.*;
class MyTableModel extends AbstractTableModel{
private String[]columnNames={"NOM","PRENOM","AGE "};
private String[][] data=new String[10][3];
MyTableModel(){
for (int i=0; i<10;i++) {
data[i][0]=new String ("fffjf");
data[i][1]=new String ("i*2");
data[i][2]=new String ("i*3");
}}
public String defin(String a,String b,String c, int l){
return data[l][0]=a;
data[l][1]=b;
data[l][2]=c;
}
public int getColumnCount(){return columnNames.length;}
public int getRowCount(){return data.length;}
public String getColumnName(int col){return columnNames[col];}
public Object getValueAt(int row,int col){return data[row][col];}
}
class Table extends JFrame implements TableModelListener {
JTextField t1,t2,t3,t4;
JButton b1;
Table(){
t1=new JTextField();
t2=new JTextField();
t3=new JTextField();
t4=new JTextField();
b1=new JButton("affecter");
// this.getContentPane().setLayout(null);
t1.setBounds(20,200,100,30);
this.getContentPane().add(t1);
t2.setBounds(20,240,100,30);
this.getContentPane().add(t2);
t3.setBounds(20,280,100,30);
this.getContentPane().add(t3);
t4.setBounds(20,320,100,30);
this.getContentPane().add(t4);
b1.setBounds(150,200,100,30);
this.getContentPane().add(b1);
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JTable MyTable=new JTable(new MyTableModel());
}
});
// JTable MyTable=new JTable(new MyTableModel());
JScrollPane MyScrollPane=new JScrollPane(MyTable);
this.getContentPane().add(MyScrollPane);
this.setSize(400,400);
this.setLocation(360,40);
}
public void tableChanged(TableModelEvent e){
}
public static void main(String args[]){
Table application=new Table();
application.setVisible(true);
application.setTitle("Exemple Table");
}
}
("il faut crée la table avec l'access ").
bon courage
----------------------------------------------------------------------------
salutttttttttttttttt coucou !!!!!!!!!!!
j'éspére que c'est ça ton bonheur.................
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import javax. swing.event.TableModelListener;
import javax.swing.event.TableModelEvent;
import javax.swing.*;
import java.sql.*;
class MyTableModel extends AbstractTableModel{
private String[]columnNames={"NOM","PRENOM","AGE "};
private String[][] data=new String[10][3];
MyTableModel(){
for (int i=0; i<10;i++) {
data[i][0]=new String ("fffjf");
data[i][1]=new String ("i*2");
data[i][2]=new String ("i*3");
}}
public String defin(String a,String b,String c, int l){
return data[l][0]=a;
data[l][1]=b;
data[l][2]=c;
}
public int getColumnCount(){return columnNames.length;}
public int getRowCount(){return data.length;}
public String getColumnName(int col){return columnNames[col];}
public Object getValueAt(int row,int col){return data[row][col];}
}
class Table extends JFrame implements TableModelListener {
JTextField t1,t2,t3,t4;
JButton b1;
Table(){
t1=new JTextField();
t2=new JTextField();
t3=new JTextField();
t4=new JTextField();
b1=new JButton("affecter");
// this.getContentPane().setLayout(null);
t1.setBounds(20,200,100,30);
this.getContentPane().add(t1);
t2.setBounds(20,240,100,30);
this.getContentPane().add(t2);
t3.setBounds(20,280,100,30);
this.getContentPane().add(t3);
t4.setBounds(20,320,100,30);
this.getContentPane().add(t4);
b1.setBounds(150,200,100,30);
this.getContentPane().add(b1);
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JTable MyTable=new JTable(new MyTableModel());
}
});
// JTable MyTable=new JTable(new MyTableModel());
JScrollPane MyScrollPane=new JScrollPane(MyTable);
this.getContentPane().add(MyScrollPane);
this.setSize(400,400);
this.setLocation(360,40);
}
public void tableChanged(TableModelEvent e){
}
public static void main(String args[]){
Table application=new Table();
application.setVisible(true);
application.setTitle("Exemple Table");
}
}
("il faut crée la table avec l'access ").
bon courage
----------------------------------------------------------------------------
salutttttttttttttttt coucou !!!!!!!!!!!
17 mars 2008 à 22:40