LOL :)
oui, c'était plus pour reprendre l'idée de sa boucle, mais je te concède que c'est une ABERRATION ;) et je te rassure, je n'écris jamais ce genre de mocheté dans la vraie vie :mrgreen:
Version imprimable
Ok beh alors tu as pas besoin de faire deux fois les if... il te suffit de faire un fonction avec tes if genre transcription. Et tu l'appelle dans ta boucle pour créer ta nouvelle chaîne traduite...
Un truc dans ce gout la... J'ai pas testé mais c'est l'idée, si j'ai bien compris ton problème...Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 private String transcriptionUnChar(char monChar){ String transcription=""; // Tous tes if... pour donner la valeur de ta traduction en fonction du char return transcription; } private String transcriptionTab(char[] monTab){ String traductionMot=""; for (int i = 0 ; i< monTab.length){ traductionMot+=transcriptionUnChar(monTab[i]); } return traductionMot; }
Hum, comment je peut faire pour accéder à une classe interne?
et de l'autre coté j'ai ma classe avec les méthode de traduction C.Code:
1
2
3
4
5
6
7 class A { class B { } }
Je souhaiterais accéder à B depuis C.
alors j'ai vu le code suivant:
mais sa ne fonctionne pas, dès le début du code.Code:
1
2 A.B aB = (new A).new B();
édit: Nan nan sa marche c'est bon, je suis juste bourré:oops:, j'essayais de mettre un variable aA objet instance de A à la place de A dans la formule précédente.
Serais-t-il possible de rendre ta méthode static tchize_? parce que sinon ça m'oblige à passer les valeur d'une classe à une autre et je me tape une erreur que je n'arrive pas à résoudre et qui m'a déjà posé des problème pour d'autre truc, Exception in thread "main" java.lang.StackOverflowError.
stackoverflow -> t'es en boucle infinie:
quelle erreur ca te pose que ces méthodes ne soient pas statiques? tu peux les mettre en static sans problème, tant que les méthodes restent sans état, l'instance n'est pas nécessaire.
StackOverFlow--> ok:ccool:
Hum statique, parce que je pensais que StackOverFlow était lié à une mauvaise instanciation d'une de mes classes. Donc pour contourner je pensais en static.
Mais le problème de l'erreur compris pour moi, je vai me tourner vers le for de ta méthode qui je crois tourne dans le vide.
édit: Visiblement ce n'est pas ça non plus, je suis un peu pomé.Code:
1
2
3
4
5 for (char c : s.toCharArray ()) { sb.append (convertCharacter (c)); }
si vous postiez la stacktrace de votre erreur?
Voici l'erreur:
et on retrouve "at package.FenetrePrincipale.<init>(FenetrePrincipale.java:20)Code:
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 Exception in thread "main" java.lang.StackOverflowError at javax.swing.text.StyleContext$SmallAttributeSet.equals(Unknown Source) at java.util.WeakHashMap.eq(Unknown Source) at java.util.WeakHashMap.get(Unknown Source) at java.util.Collections$SynchronizedMap.get(Unknown Source) at javax.swing.text.StyleContext.getImmutableUniqueSet(Unknown Source) at javax.swing.text.StyleContext.addAttributes(Unknown Source) at javax.swing.text.AbstractDocument$AbstractElement.addAttributes(Unknown Source) at javax.swing.text.AbstractDocument$AbstractElement.<init>(Unknown Source) at javax.swing.text.AbstractDocument$LeafElement.<init>(Unknown Source) at javax.swing.text.AbstractDocument$BidiElement.<init>(Unknown Source) at javax.swing.text.AbstractDocument.<init>(Unknown Source) at javax.swing.text.AbstractDocument.<init>(Unknown Source) at javax.swing.text.PlainDocument.<init>(Unknown Source) at javax.swing.text.PlainDocument.<init>(Unknown Source) at javax.swing.text.DefaultEditorKit.createDefaultDocument(Unknown Source) at javax.swing.plaf.basic.BasicTextUI.installUI(Unknown Source) at javax.swing.JComponent.setUI(Unknown Source) at javax.swing.text.JTextComponent.setUI(Unknown Source) at javax.swing.text.JTextComponent.updateUI(Unknown Source) at javax.swing.text.JTextComponent.<init>(Unknown Source) at javax.swing.JTextField.<init>(Unknown Source) at javax.swing.JTextField.<init>(Unknown Source) at package.PanelLabel.<init>(PanelLabel.java:20) at package.FenetrePrincipale.<init>(FenetrePrincipale.java:16) at package.TradTool.<init>(TradTool.java:41) at package.FenetrePrincipale.<init>(FenetrePrincipale.java:20) at package.TradTool.<init>(TradTool.java:41)
at package.TradTool.<init>(TradTool.java:41)"
sur encore beaucoup de ligne sans variante.
t'as une récusrsion infinie de constructeur:
TradTool crée un FenetrePrincipal qui crée un TradTool qui crée un FenetrePrincipal etc
Ben dans ma classe FenetrePrincipale, j'ai un:
et dans trad j'ai:Code:
1
2
3
4
5
6
7 private TradTool unTradTool = new TradTool (); public FenetrePrincipale TradTool aTrad) { this.unTradTool = aTrad; }
qu'est-ce que j'ai loupé et qui m'a pas loupé ?Code:
1
2
3
4
5
6
7 public FenetrePrincipale fp = new FenetrePrincipale (); public TradTool (FenetrePrincipale aFp) { this.fp = aFp; }
les deux new font implictement partie du constructeur. Votre code équivaut à
Pareil pour l'autre. La boucle est assez évidente à partir de là ;) (new appelle new qui appelle new qui ....Code:
1
2
3
4
5
6
7 private TradTool unTradTool; public FenetrePrincipale (TradTool aTrad) { unTradTool = new TradTool (); this.unTradTool = aTrad; }
Remplacez par
idem pour l'autre classe.Code:
1
2
3
4
5
6 private TradTool unTradTool; public FenetrePrincipale (TradTool aTrad) { this.unTradTool = aTrad; }
Je suis d'accord mais ce que je ne comprend pas, c'est que mon unTradTool, s'il n'est pas instancié ne devrait pas exister non?
Parce que lorsque je lance le programme après votre modification, il me met un null pointeur sur la ligne:
unPanellabel.getLabelResult ().setText (unTradTool.getTextFinal ());
Donc de ce que je comprend il ne trouve pas unTradTool.
édit: En plus je me rend compte que c'est exactement le même délire sur un autre programme que je fais actuellement, et j'avais changé complètement de structure à cause de ça.Code:
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 Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at package.FenetrePrincipale$GestionnaireAction.actionPerformed(FenetrePrincipale.java:64) 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.AbstractButton.doClick(Unknown Source) at javax.swing.plaf.basic.BasicRootPaneUI$Actions.actionPerformed(Unknown Source) at javax.swing.SwingUtilities.notifyAction(Unknown Source) at javax.swing.JComponent.processKeyBinding(Unknown Source) at javax.swing.KeyboardManager.fireBinding(Unknown Source) at javax.swing.KeyboardManager.fireKeyboardAction(Unknown Source) at javax.swing.JComponent.processKeyBindingsForAllComponents(Unknown Source) at javax.swing.JComponent.processKeyBindings(Unknown Source) at javax.swing.JComponent.processKeyEvent(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.KeyboardFocusManager.redispatchEvent(Unknown Source) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(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.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$000(Unknown Source) at java.awt.EventQueue$1.run(Unknown Source) at java.awt.EventQueue$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$2.run(Unknown Source) at java.awt.EventQueue$2.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(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)
résoudre ça m'aiderais beaucoup pour l'autre.
voici le lien de référence à l'autre problème que j'avais eu:
http://www.developpez.net/forums/d10.../gouffre-code/
vous ne pouvez pas faire ça
Puisque comme vous le voyez vous avec une boucle là.Code:
1
2
3
4
5
6 public class X { Y y = new Y(); } public class Y { X x= new X(); }
vous devez travailler en deux temps et passer les paramètres correctement à vos constructeurs / setters : si vous voulez que deux instances de x et y se voient mutuellement.
Si vous avez desn ullpointerexception c'est que vous avez oublié la partie initialisation. Il faudra de toutes façons que vous décidiez de l'ordre dans lequel vous voulez instancier vos classes.Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 public class X { Y y; public X(Y y){ this.y = y; } } public class Y { X x; public Y(){ x = new X(this); } } //main: Y y = new Y();
okay d'accord je vais ordonner tous ça voir ce que ça donne.
Bon ben c'est nickel, merci pour l'aide à tous le monde, et tchize_ pour les conseils de fin qui comblent mon manque de savoir sur certain points.
En plus de finir mon projet de taf, je me suis fait une une version vierge du programme, au format le plus simple, vide de caractère, on s'est jamais ça peut servir.
Si vous voulez les sources (vierge et simples) mp moi.:D