Bonjour,

Voila j'essai désespérément d'afficher le contenu d'un JTextArea dans un autre lorsque l'on appuie sur la touche entrée mais hélas ce que j'ai fais ne marche pas et je ne comprend pas pourquoi Voici mon 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
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
package client;
 
import java.awt.BorderLayout;
 
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
//import javax.swing.JMenuItem;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
 
public class InterfaceGraphique extends JFrame {
	private static final long serialVersionUID = -2040488316874518030L;
	JPanel panel = new JPanel ();
	JPanel result = new JPanel ();
	JSplitPane split = new JSplitPane (JSplitPane.VERTICAL_SPLIT, panel, result);
	JTextArea envoieTexte = new JTextArea (5, 55);
	JTextArea receptionTexte = new JTextArea (20, 55);
	JScrollPane scroll = new JScrollPane ();
 
		public InterfaceGraphique () {
			build (); //On initialise notre fenetre
		}
 
		private void build () {
			JMenuBar menuBar = new JMenuBar ();
			JMenu menu1 = new JMenu ("Fichier");
			//JMenuItem quitter = new JMenuItem (new QuitterAction ("Quitter"));
			JMenu menu2 = new JMenu ("?");
			//JMenuItem aPropos = new JMenuItem (new AProposAction (this, "A propos"));
 
		    //menu1.add (quitter);
			menuBar.add (menu1);
			//menu2.add (aPropos);
			menuBar.add (menu2);
			setJMenuBar (menuBar);
			setTitle ("Tchat"); //On donne un titre a l'application
			setSize (640, 480); //On donne une taille a notre fenetre
			setLocationRelativeTo (null); //On centre la fenêtre sur l'écran
			setResizable (true); //On autorise le redimensionnement de la fenetre
			setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); //On dit a l'application de se fermer lors du clic sur la croix
			getContentPane ().add (this.split, BorderLayout.CENTER);
			getContentPane ().add (buildContentPane (), BorderLayout.NORTH);
			getContentPane ().add (this.result.add (this.envoieTexte), BorderLayout.SOUTH);
			//this.receptionTexte.setText("iluwdfghgiudrgh\niosrughiurh");
			this.envoieTexte.setFocusable (true);
			this.envoieTexte.requestFocus ();
			InputMap inputMap = this.envoieTexte.getInputMap();
			ActionMap actionMap = this.envoieTexte.getActionMap ();
			inputMap.put (KeyStroke.getKeyStroke ("Entrée"), "envoiTexte");
			actionMap.put ("envoiTexte", new GetAction (this));
		}
 
		private JPanel buildContentPane () {
			//this.scroll.add (this.receptionTexte);
			//this.panel.add (this.scroll);
			this.receptionTexte.setLineWrap (true);
			this.receptionTexte.setEditable (false);
			this.panel.add (this.receptionTexte);
			//this.panel.setLayout (new FlowLayout ());
 
			return panel;
		}
 
		public JTextArea getEnvoieTexte () {
			return this.envoieTexte;
		}
 
		public JTextArea getReceptionTexte () {
			return this.receptionTexte;
		}
}
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
package client;
 
import java.awt.event.ActionEvent;
 
import javax.swing.AbstractAction;
 
public class GetAction extends AbstractAction {
	private static final long serialVersionUID = -4643889046538595704L;
	private InterfaceGraphique fenetre;
 
		public GetAction (InterfaceGraphique fenetre) {	
			this.fenetre = fenetre;
		}
 
		public void actionPerformed(ActionEvent e) { 
			String texteUtilisateur = fenetre.getEnvoieTexte ().getText ();
 
			fenetre.getReceptionTexte ().setText (texteUtilisateur);
		}
}
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
package client;
 
import javax.swing.SwingUtilities;
 
public class TestInterface {
	public static void main(String[] args) {
		SwingUtilities.invokeLater (new Runnable (){
			public void run (){
				//On cree une nouvelle instance de la fenetre
				InterfaceGraphique fenetre = new InterfaceGraphique ();
				fenetre.setVisible (true); //On la rend visible
			}
		});
	}
}
Si quelqu'un peut m'aider à comprendre ce qui ne va pas Merci d'avance.