sarha1
Messages postés11Date d'inscriptionlundi 5 mars 2012StatutMembreDernière intervention23 mai 2012
-
20 mars 2012 à 01:10
sarha1
Messages postés11Date d'inscriptionlundi 5 mars 2012StatutMembreDernière intervention23 mai 2012
-
21 mars 2012 à 17:16
bonsoir, je me bloque a cett étape, en faite j'ai deux classe dans la premiére que je l'ai nommé "liste_patient", ici j'ai définit une méthode "affichage() " public qui retourne un String
jusqu’à ici pas de problème . je veux appeler cette méthode à partir d'une deuxième classe nommé commande
donc donc la classe commande j'ai :
liste_patient f= new liste_patient();
f.affichage();
voila comment j'ai définit la méthode
public String affichage()
{
..........
return String ;
}
mais lorsque j'ai compile:
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
cs_Julien39
Messages postés6414Date d'inscriptionmardi 8 mars 2005StatutModérateurDernière intervention29 juillet 2020371 20 mars 2012 à 08:21
Bonjour,
Si ta méthode des static, tu ne peux pas l'appeler sur un objet : f.affichage() mais il faut l'appeler en donnant le nom de la classe dans laquelle elle se trouve : liste_patient.affichage()
cs_Julien39
Messages postés6414Date d'inscriptionmardi 8 mars 2005StatutModérateurDernière intervention29 juillet 2020371 20 mars 2012 à 08:27
Et essaye de respecter les conventions de nommage en jave, une classe commence par une majuscule et les mots sont séparés par des majuscules : ClasseExemple
cs_Julien39
Messages postés6414Date d'inscriptionmardi 8 mars 2005StatutModérateurDernière intervention29 juillet 2020371 20 mars 2012 à 08:28
Tu n'utilises pas d'ide : un ide n'aurait pas laissé passer une telle erreur. Je te conseil donc de télécharger Eclipse, tu vas gagner un temps infini !
sarha1
Messages postés11Date d'inscriptionlundi 5 mars 2012StatutMembreDernière intervention23 mai 2012 20 mars 2012 à 20:33
bonsoir Julien39,
la méthode affichage() n'est pas une méthode static normalement, je l'ai définit avec "public" mais j'ai commis une erreur en tapant le nom de sujet.
j'ai essayé avec liste_patient.affichage() mais il n'accepte pas, elle est souligné en rouge !!!!! donc quoi je faire???
oui j’utilise déjà l’Éclipse Indigno
merci comme même pour votre réponse
a++
Vous n’avez pas trouvé la réponse que vous recherchez ?
cs_Julien39
Messages postés6414Date d'inscriptionmardi 8 mars 2005StatutModérateurDernière intervention29 juillet 2020371 21 mars 2012 à 08:12
Et quelle erreur est indiquée quand tu passes le curseur au dessus du carré rouge ?
Peux tu me donner un code un peu plus complet : celui de l'appel de la méthode affichage. Si cette méthode retourne un String, il faudrait en faire quelque chose non ? Comme un System.out.println() ?
sarha1
Messages postés11Date d'inscriptionlundi 5 mars 2012StatutMembreDernière intervention23 mai 2012 21 mars 2012 à 17:16
**bonjour,enfin j'ai arrivé a envoyer un texte dans un textfield appartenant à une deuxième classe
mais pour mon projet je dois récupérer le texte selectionné dans un tableau dans le textfield de la deuxième classe, il n’y pas des erreur mais rien ne s'affiche, voila la methode :
public String afficher()
{
int r = tableau.getSelectedRow();
Object m=tableau.getModel().getValueAt(r,tableau.getSelectedColumn());
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.Vector.elementAt(Unknown Source)
at javax.swing.table.DefaultTableModel.getValueAt(Unknown Source)
at liste_patient.afficher(liste_patient.java:411)
at commande.(commande.java:58)
at liste_patient$7.actionPerformed(liste_patient.java:291)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.Vector.elementAt(Unknown Source)
at javax.swing.table.DefaultTableModel.getValueAt(Unknown Source)
at liste_patient.afficher(liste_patient.java:411)
at commande.(commande.java:58)
at liste_patient$7.actionPerformed(liste_patient.java:291)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)