Probleme avec Jtable

Résolu
eccsup Messages postés 77 Date d'inscription jeudi 14 mai 2009 Statut Membre Dernière intervention 14 novembre 2022 - 13 févr. 2011 à 12:55
eccsup Messages postés 77 Date d'inscription jeudi 14 mai 2009 Statut Membre Dernière intervention 14 novembre 2022 - 18 févr. 2011 à 11:18
Bonjour a tous,

voila j'ai un probleme, ca fait un moment que je cherche la solution mais pas moyen de comprendre ce qui va pas:

Je cherche a ecrire une JTable dynamique avrc une methode ajouter, ect...
D'ailleurs, elle marche très bien sauf que les données qui s'affiche dans ma table sont de la forme

"java.lang.Object@64565454"

Voila mon code, je l'ai coparé avec ceux de nombreux tutoriels et je n'ai pas vu de différences.

classe Modele, pour la JTable
public class Modele extends AbstractTableModel {

    private final String[] columnNames={"numero","nom","arrondissement","localisation"};

    private List data=new ArrayList();

    

    public void initialise(){
        Station d1=new Station("1001","Terraux/Terme",Station.getTableArr(2),"Angle rue d'Algérie");
        Station d2=new Station("bob","bob",Station.getTableArr(3),"bob");
       data.add(d1);
       data.add(d2);
       this.ajoutLigne(d2);

    }

    public void ajoutLigne(Station donnees){
        data.add(donnees);
        fireTableStructureChanged();
    }
...
}


Ma classe principal et son constructeur
public class VeloV extends javax.swing.JFrame {

   final Modele monModel;
private javax.swing.JTable tableau=new Jtable();
    public VeloV() {
        
        

        monModel=new Modele();
        monModel.initialise();
        tableau.setModel(monModel);
               
       DefaultListModel listModel=new DefaultListModel();
        
        for (int i=1;i<Station.getTailleTab();i++){
            listModel.addElement(Station.getTableArr(i));
        }


        listArrondissement.setModel(listModel);

        
    }


Ma classe Station (n'aide pas a comprendre le probleme)

public class Station {

    private String numeroID;
    private String nomStation;
    private ArrondissementVille arrondissement;
    private String localisation;
    //Liste fixe des arrondissement existants
    private static List tabArrondissement=new ArrayList();
    private static boolean init=false;


    public Station(String num,String nom,ArrondissementVille arr,String loc){
         initArrondissement();
         numeroID=num;
        nomStation=nom;
        arrondissement=(arr);
        localisation=loc;
       
    }

    public static void initArrondissement(){
        if (init==false){
       tabArrondissement.add(new ArrondissementVille(1,"1er Arrondissement"));
       tabArrondissement.add(new ArrondissementVille(2,"2eme Arrondissement"));
       tabArrondissement.add(new ArrondissementVille(3,"3eme Arrondissement"));
       tabArrondissement.add(new ArrondissementVille(4,"4eme Arrondissement"));
       tabArrondissement.add(new ArrondissementVille(5,"5eme Arrondissement"));
       tabArrondissement.add(new ArrondissementVille(6,"6eme Arrondissement"));
       tabArrondissement.add(new ArrondissementVille(7,"7eme Arrondissement"));
       init=true;
        }
    }

    public String getNumero(){
        return numeroID;
    }

    public String getNom(){
        return nomStation;
    }

    public String getLocalisation(){
        return localisation;
    }
    public void setNumero(String num){
        numeroID=num;
    }
    public void setNom(String nom){
        nomStation=nom;
    }
    public void setlocalisation(String loc){
        localisation=loc;
    }
    public ArrondissementVille getArrondissement(){
        return arrondissement;
    }
    public void setArrondissement(ArrondissementVille arr){
        arrondissement.affecte(arr);
    }

    public static ArrondissementVille getTableArr(int i){
        initArrondissement();
        return tabArrondissement.get(i-1);
    }

    public static int getTailleTab(){
        initArrondissement();
        return (tabArrondissement.size())+1;
    }

}


Voila, si quelqu'un pouvait me dire pourquoi toutes les case de mon Tableau sont de la forme java.lang.Object@44654

merci d'avance

3 réponses

eccsup Messages postés 77 Date d'inscription jeudi 14 mai 2009 Statut Membre Dernière intervention 14 novembre 2022
18 févr. 2011 à 11:18
Du coup j'ai trouvé mon problème, j'avais oublié d'implementer la methode getValueAt(int,int).

Désolé pour le derangement

Voila, ca poura aidé si quelqu'un a fait la meme boulette
3
eccsup Messages postés 77 Date d'inscription jeudi 14 mai 2009 Statut Membre Dernière intervention 14 novembre 2022
14 févr. 2011 à 11:14
Up
0
eccsup Messages postés 77 Date d'inscription jeudi 14 mai 2009 Statut Membre Dernière intervention 14 novembre 2022
16 févr. 2011 à 11:06
Personne ne peut m'aider?
0
Rejoignez-nous