IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Collection et Stream Java Discussion :

Manipulation ArrayList dans ArrayList


Sujet :

Collection et Stream Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2015
    Messages
    45
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2015
    Messages : 45
    Par défaut Manipulation ArrayList dans ArrayList
    Bonsoir,
    Avant de vous exposer mon problème je tiens au vous remercier pour l’aider que vous m’apporter.

    Je rencontre au souci avec la manipulation d’ArrayList.
    Dans la classe Formulaire :
    J’ai mon ArrayList graphe où je vais stocker des ArrayList
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    public class Formulaire extends JFrame implements ActionListener, WindowListener {	
    	ArrayList graphe = new ArrayList();
    Dans la même classe quand je clique sur le bouton add de mon interface ca lance ce code
    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
     
    if(e.getSource() == jButtonAdd){				
    	//index0: le nom du graph
    	//index1: le nom du paramètre
    	//index2: la position du paramètre dans la liste
    	//index3: L'unité
    	//index4: data
    	ArrayList cons_Graph = new ArrayList();
    	cons_Graph.add(jTextFieldNom_Graph.getText());
    	cons_Graph.add(listParam.getSelectedItem());
    	cons_Graph.add(listParam.getSelectedIndex());
    	cons_Graph.add(rf.unite(listParam.getSelectedIndex()));				
    if((jTextFieldNom_Graph.getText().length() > 0) && (listParam.getSelectedIndex() != -1)){
    	listGraph.add(jTextFieldNom_Graph.getText());
     
    	cons_Graph.add(rf.paramData(listParam.getSelectedIndex()));
    	graphe.add(cons_Graph);
    Le souci se trouve quand je veux rajouter mon ArrayList cons_Graph dans mon ArrayList graphe ou je stocke l’ensemble des informations de mes graphes

    La fonction ci-dessous me retourne une ArrayList
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    cons_Graph.add(rf.paramData(listParam.getSelectedIndex()));
    Sauf que quand je clique une nouvelle fois ca va m’écraser toutes mes autres valeurs à l’index4 où j’ai le retour de ma fonction.

    Je vais prendre un exemple pour bien que vous compreniez, quand je clic la première fois, l’état de la ArrayList graphe :

    index0 : [graphe1, MASSE, 0, DEG, [4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0, 4600.0]]

    Ok c’est bon c’est ce que je veux, mais la deuxième fois problème :

    index0 : [graphe1, MASSE, 0, DEG, [210.00, 134.00, 93.000, 88.000, 109.00, 144.00, 210.00, 94.000, 65.000, 62.000, 77.000, 106.00, 200.00, 154.00, 210.00, 103.00, 71.000, 68.000, 76.000, 96.000, 200.00, 100.00, 68.000, 65.000, 71.000, 91.000, 200.00, 101.00]]

    index1 : [Graphe2, VIT VENT, 4, DEG, [210.00, 134.00, 93.000, 88.000, 109.00, 144.00, 210.00, 94.000, 65.000, 62.000, 77.000, 106.00, 200.00, 154.00, 210.00, 103.00, 71.000, 68.000, 76.000, 96.000, 200.00, 100.00, 68.000, 65.000, 71.000, 91.000, 200.00, 101.00]]
    Ca m’a écrasé mes valeurs à l’index0 ! En cinquième position mon ArrayList est systématiquement remplacé par le dernier relevé.

    J’ai cherché toute l’après midi sans trouver de solution.
    Est-ce que vous voyez mon problème ?
    Merci pour vos réponses

  2. #2
    Expert éminent
    Avatar de adiGuba
    Homme Profil pro
    Développeur Java/Web
    Inscrit en
    Avril 2002
    Messages
    13 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java/Web
    Secteur : Transports

    Informations forums :
    Inscription : Avril 2002
    Messages : 13 938
    Billets dans le blog
    1
    Par défaut
    Salut,


    Des ArrayList d'ArrayList ! Pas terrible.
    Il serait préférable de manipuler une liste d'objet spécifique...


    Sinon pour revenir à ton problème, il faudrait voir comment sont créer tes valeurs.
    Je pense que tu dois réutiliser la même structure, d'où le fait que les données soit écrasé...


    a++

  3. #3
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2015
    Messages
    45
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2015
    Messages : 45
    Par défaut
    La classe Formulaire

    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
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    package graphique;
    
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.FlowLayout;
    import java.awt.GridLayout;
    import java.awt.List;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowListener;
    import java.util.ArrayList;
    
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    
    import org.jfree.ui.RefineryUtilities;
    
    import fichier.RecupFichier;
    import graphique2.Graph;
    
    public class Formulaire extends JFrame implements ActionListener, WindowListener {
    	
    	JLabel jLabelNom_Graph = new JLabel("Nom du graphique :");
    	JTextField jTextFieldNom_Graph = new JTextField(12);
    	JButton jButtonAdd = new JButton("Add");
    	JButton jButtonDlt = new JButton("Dlt");
    	JButton jButtonGene = new JButton("Générer");
    	JLabel jLabelParam = new JLabel("Paramètre(s)");
    	List listParam = new List();
    	JLabel jLabelGraph = new JLabel("Mes graphique(s)");
    	List listGraph = new List();
    	JLabel jLabelSt = new JLabel("Statut du traitement");	
    	
    	ArrayList graphe = new ArrayList();
    	
    	RecupFichier rf = new RecupFichier();
    	
    	JFrame jFrameGraphes = new JFrame();
    	JPanel jPanelGraphes = new JPanel();
    	JButton jButtonGraphes = new JButton("Graphe");
    	
    	public Formulaire() {
    	//Construction de ma JFrame pour l'affichage des graphes
    		jFrameGraphes.setLayout(new BorderLayout());
    		jPanelGraphes.setLayout(new GridLayout(2,1));
    		jFrameGraphes.setBounds(900,250,750,600);
    	//----------------------------------------
    	//Gestion de la disposition des éléments
    		this.setLayout(new BorderLayout());
    		
    		JPanel jPanelN = new JPanel();
    		jPanelN.setLayout(new FlowLayout());
    		jPanelN.add(jLabelNom_Graph);
    		jPanelN.add(jTextFieldNom_Graph);
    		jPanelN.add(jButtonAdd);
    		jPanelN.add(jButtonDlt);
    		jPanelN.add(jButtonGene);
    		this.add(jPanelN, BorderLayout.NORTH);
    		
    		JPanel jPanelC = new JPanel();
    		jPanelC.setLayout(new GridLayout());
    	
    		jPanelC.add(jLabelGraph);
    		jPanelC.add(listParam);
    		jPanelC.add(listGraph);
    		this.add(jPanelC, BorderLayout.CENTER);
    		
    		this.add(jLabelParam, BorderLayout.WEST);
    		this.add(jLabelGraph, BorderLayout.EAST);
    		
    		this.add(jLabelSt, BorderLayout.SOUTH);
    	//--------------------------------------------	
    	//Gestion des évènements sur les boutons
    		jButtonAdd.addActionListener(this);
    		jButtonDlt.addActionListener(this);
    		jButtonGene.addActionListener(this);
    	//--------------------------------------------
    	//Gestion des évènements sur la fenêtre
    		this.addWindowListener(this);
    	//--------------------------------------------
    		
    	//Elements spécifique à* ma fenetre	
    		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    		this.setBounds(900,250,750,600);
    		this.setAlwaysOnTop(true);
    		this.setVisible(true);
    	//--------------------------------------------
    	}
    
    	/*private void chargParam() {
    		listParam.add("MASSE");
    		listParam.add("PSI");
    		listParam.add("CAP VENT");
    		listParam.add("VIT VENT");
    		listParam.add("FORCE MER");
    	}*/
    	
    	public void afficherGraphes(){
    		//System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
    		ArrayList afficher = new ArrayList();
    		for(int i=0;i<graphe.size();i++ ){
    			afficher.add(graphe.get(i));
    			System.out.println("index"+i+" : "+afficher.get(i));
    		}
    		//System.out.println(graphe);
    	}
    	
    	public void actionPerformed(ActionEvent e){
    		jLabelSt.setText("OK");
    		if(e.getSource() == jButtonAdd){
    			//try{
    				if((jTextFieldNom_Graph.getText().length() == 0) && (listParam.getSelectedIndex() == -1)){
    					jLabelSt.setText("Erreur: Veuillez  entrer un nom pour le graphique et choisir un paramètre");
    				}else if(jTextFieldNom_Graph.getText().length() == 0){
    					jLabelSt.setText("Erreur: Veuillez entrer un nom pour le graphique");
    				}
    				else if(listParam.getSelectedIndex() == -1){
    					jLabelSt.setText("Erreur: Veuillez choisir un paramètre");
    				}
    				//index0: le nom du graph
    				//index1: le nom du paramètre
    				//index2: la position du paramètre dans la liste
    				//index3: L'unité
    				//index4: data
    				
    				ArrayList cons_Graph = new ArrayList();
    				cons_Graph.add(jTextFieldNom_Graph.getText());
    				cons_Graph.add(listParam.getSelectedItem());
    				cons_Graph.add(listParam.getSelectedIndex());
    				cons_Graph.add(rf.unite(listParam.getSelectedIndex()));
    				
    				if((jTextFieldNom_Graph.getText().length() > 0) && (listParam.getSelectedIndex() != -1)){
    					listGraph.add(jTextFieldNom_Graph.getText());
    						/*ArrayList child_para = (ArrayList) data.get(0);
    						for(int i=0; i<child_para.size();i++){
    							madata.add(child_para.get(i));
    						}*/
    					cons_Graph.add(rf.paramData(listParam.getSelectedIndex()));
    					graphe.add(cons_Graph);
    					
    				}
    					
    			//}
    			/*catch(Exception e2){
    				if(listParam.getSelectedIndex() == -1){
    					jLabelSt.setText("Erreur: Veuillez choisir un paramètre ici");
    				}	
    				System.out.println("bug");
    			}*/
    			afficherGraphes()
    		}
    		if(e.getSource() == jButtonDlt){
    			int indexGraph = listGraph.getSelectedIndex();
    			try{
    					//System.out.println(listGraph.getSelectedIndex());
    				listGraph.remove(indexGraph);
    				graphe.remove(indexGraph);
    			}
    			catch(Exception e2){
    				if(indexGraph == -1){
    					jLabelSt.setText("Erreur: Veuillez choisir un graphique à* supprimer");
    				}
    			}
    			afficherGraphes();
    		}
    		if(e.getSource() == jButtonGene){
    			if(listGraph.countItems()>0)
    			{
    				
    				for(int i=0;i<graphe.size();i++){
    					ArrayList mongraphe = (ArrayList) graphe.get(i);
    					//index0: le nom du graph
    					//index1: le nom du paramètre
    					//index2: la position du paramètre dans la liste
    					//index3: L'unité
    					//index4: résultats
    					
    					//Récupère les résultats
    					String resultat[] = new String[100];
    					ArrayList mesresultats = (ArrayList) mongraphe.get(4);
    					for(int j=0;j<mesresultats.size();j++){
    						resultat[j] = (String) mesresultats.get(j);
    						//System.out.println(resultat[j]);
    					}
    					
    					final Graph demo = new Graph("Résultat",(String)mongraphe.get(1), resultat, "unité",mesresultats.size());
    					/*demo.pack();
    					RefineryUtilities.centerFrameOnScreen(demo);
    					demo.setVisible(true);
    					demo.setAlwaysOnTop(true);*/
    					
    					jPanelGraphes.add(demo.chartPanel);
    					jFrameGraphes.setVisible(true);
    					jFrameGraphes.add(jPanelGraphes, BorderLayout.CENTER);
    				}
    			}
    			else{
    				jLabelSt.setText("Erreur: Vous avez construit aucun graphique");
    			}
    		}
    		
    	}
    
    //Gestion des évènements sur la fenêtre----------------------
    	public void windowActivated(WindowEvent arg0) {
    		
    	}
    	
    	public void windowClosed(WindowEvent arg0) {
    		// TODO Auto-generated method stub
    		
    	}
    
    	public void windowClosing(WindowEvent arg0) {
    		// TODO Auto-generated method stub
    		
    	}
    
    	public void windowDeactivated(WindowEvent arg0) {
    		// TODO Auto-generated method stub
    		
    	}
    
    	public void windowDeiconified(WindowEvent arg0) {
    		// TODO Auto-generated method stub
    		
    	}
    
    	public void windowIconified(WindowEvent arg0) {
    		// TODO Auto-generated method stub
    		
    	}
    
    	public void windowOpened(WindowEvent arg0) {
    		
    		ArrayList parentList = new ArrayList();
    		ArrayList childList = new ArrayList();
    
    		parentList.add(rf.parametresFichier());		
    
    		ArrayList child = (ArrayList) parentList.get(0);
    		for(int j=0 ;j<child.size();j++){
    			listParam.add((String) child.get(j));
    		}
    			
    	}
    //------------------------------------------------------
    }
    Ca fonctionne bien mais c'est quand je mets l'ArrayList dans L'ArrayList de L'ArrayList qu'il écrase mes autres ArrayList

    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
    package fichier;
    
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.util.ArrayList;
    
    
    import fichier_recup.*; 
    
    public class RecupFichier {
    	
    	final SeeFile see = new SeeFile("test_ini.SEE");
    	ArrayList listParam = new ArrayList();
    	ArrayList listParamData = new ArrayList();
    	
    	public RecupFichier() {
    		try {
    			see.load();
    		} catch (FileNotFoundException e1) {
    			// TODO Auto-generated catch block
    			e1.printStackTrace();
    		} catch (IOException e1) {
    			// TODO Auto-generated catch block
    			e1.printStackTrace();
    		} catch (HeaderException e1) {
    			// TODO Auto-generated catch block
    			e1.printStackTrace();
    		} catch (SeeDataException e1) {
    			// TODO Auto-generated catch block
    			e1.printStackTrace();
    		}
    	}
    	
    	public ArrayList parametresFichier(){
    		
    		final SeeParameter[] prms = see.getParametersList();
    		for(int i=0; i<prms.length; i++)
    			listParam.add(prms[i].getName());
    		
    		return listParam;
    	}
    	
    	public ArrayList paramData(int index){
    		listParamData.clear();
    		index = index + 1;
    		String[] tab = see.getParameterValues(index);
    		
    		for(String tab_string : tab ){
    			listParamData.add(tab_string);
    		}
    		//System.out.println(listParamData);
    		return listParamData;
    	}
    	
    	public String[] paramData2(int index){
    		
    		index = index + 1;
    		String[] tab = see.getParameterValues(index);
    		
    		return tab;
    	}
    	
    	
    	public String unite(int index){
    		/*final SeeParameter[] prms = see.getParametersList();
    		System.out.println(prms[index].getUnit());
    		String unite = prms[index-1].getUnit();*/
    		
    		ArrayList<String> unites = new ArrayList<String>();
    		final SeeParameter[] prms = see.getParametersList();
    		for(int i=0; i<prms.length; i++)
    			unites.add(prms[i].getUnit());
    		if(index>prms.length || index<prms.length){
    			index=1;
    		}
    		
    		return unites.get(index);
    	}
    	
    }

  4. #4
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    Citation Envoyé par adiGuba Voir le message
    Salut,


    Des ArrayList d'ArrayList ! Pas terrible.

    a++
    A t'as du mal regarder les datas, c'est un ArrayList d'ArrayList avec encore une ArrayList dedans


    Citation Envoyé par johnmax Voir le message
    Ca m’a écrasé mes valeurs à l’index0 ! En cinquième position mon ArrayList est systématiquement remplacé par le dernier relevé.
    Non, ça a écrasé le valeurs contenues dans l'arraylist située à l'index 4 de l'arraylist située à l'index 0 de ton arraylist graphe (ouf!)

    Si j'en juge par ton code, cette ArrayList au contenu changeant est celle retournée par:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    cons_Graph.add(rf.paramData(listParam.getSelectedIndex()))
    Conclusion: ce bout de code retourne constement la même arrayList à chaque appel, dont elle écrase les valeurs. C'est lui qu'il faut aller voir. Et qu'est-ce que l'on voit? Qu'effectivement tu efface à chaque fois le contenu de cette liste:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    	public ArrayList paramData(int index){
    		listParamData.clear();
    		index = index + 1;
    		String[] tab = see.getParameterValues(index);
    		
    		for(String tab_string : tab ){
    			listParamData.add(tab_string);
    		}
    		//System.out.println(listParamData);
    		return listParamData;
    	}
    A noter que tu aurais tout simplement pu changer ce code par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    	public List<String> paramData(int index){
                        return Arrays.asList(see.getParameterValues(index));
    	}

  5. #5
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2015
    Messages
    45
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2015
    Messages : 45
    Par défaut
    Merci ca fonctionne!

    Par contre j'ai une erreur qui remonte :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    //Récupére les résultats
    String resultat[] = new String[100];
    ArrayList mesresultats = (ArrayList) mongraphe.get(4);
    					
    for(int j=0;j<mesresultats.size();j++){
         resultat[j] = (String) mesresultats.get(j);
         System.out.println(resultat[j]);
    }
    					
    final Graph demo = new Graph((String) mongraphe.get(0),(String)mongraphe.get(1), resultat, (String) mongraphe.get(3),mesresultats.size());
    Il me sort une erreur sur la ligne que j'ai mit en gras : Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList

  6. #6
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2015
    Messages
    45
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2015
    Messages : 45
    Par défaut
    Je te mets le code en entier :

    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
     
    for(int i=0;i<graphe.size();i++){
    	ArrayList mongraphe = (ArrayList) graphe.get(i);
    	//index0: le nom du graph
    	//index1: le nom du paramétre
    	//index2: la position du paramétre dans la liste
    	//index3: L'unité
    	//index4: résultats
     
    	//Récupére les résultats
    	String resultat[] = new String[100];
    	ArrayList mesresultats = (ArrayList) mongraphe.get(4);
    	for(int j=0;j<mesresultats.size();j++){
    		resultat[j] = (String) mesresultats.get(j);
    	        System.out.println(resultat[j]);
    	}
     
    	final Graph demo = new Graph((String) mongraphe.get(0),(String)mongraphe.get(1), resultat, (String) mongraphe.get(3),mesresultats.size());
     
     
    	jPanelGraphes.add(demo.chartPanel);
    	jFrameGraphes.setVisible(true);
    	jFrameGraphes.add(jPanelGraphes, BorderLayout.CENTER);
    }

  7. #7
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    List mesresultats = (List) mongraphe.get(4);

  8. #8
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    Encore une fois, ceci peut être allègrement remplacé:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    	//Récupére les résultats
    	String resultat[] = new String[100];
    	ArrayList mesresultats = (ArrayList) mongraphe.get(4);
    	for(int j=0;j<mesresultats.size();j++){
    		resultat[j] = (String) mesresultats.get(j);
    	        System.out.println(resultat[j]);
    	}
    en
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    	//Récupére les résultats
    	List<String> mesresultats = (List<String>) mongraphe.get(4);
    	String resultat[] = mesresultats.toArray(new String[0]);

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème d'ArrayList d'arrayList d'arrayList
    Par Shaina dans le forum Collection et Stream
    Réponses: 5
    Dernier message: 25/02/2011, 11h04
  2. Problème de Serialisation: ArrayList dans ArrayList
    Par Noursounator dans le forum ASP.NET
    Réponses: 3
    Dernier message: 30/03/2010, 13h24
  3. [C#] ArrayList dans une variable de session ?
    Par Oberown dans le forum ASP.NET
    Réponses: 1
    Dernier message: 12/12/2005, 15h50
  4. Réponses: 7
    Dernier message: 30/06/2005, 10h06
  5. [Fichier] Ajout des lignes de doc dans arraylist
    Par 3adoula dans le forum Entrée/Sortie
    Réponses: 9
    Dernier message: 29/04/2004, 22h41

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo