java - Take JTextArea and add entered contents to a label -
Basically I have a program with a card (I'm using the card layout), when the user sends some type of message or type what they do at any time, I would like to add a label to that page when it Press the button named. I'm not sure how I can save the entry area and keep it as a variable in the label. any idea? I can provide my code if needed.
> > >
6 "); String theText = descriptionField.getText (); FictionDescallabel. Set Text (Text); Stability Disclosure.Setbones (250, 150, 200, 40); Joint (Stability Disclaimer);}});
It is very straight forward.
TextArea:
string TheText = myTextArea.getText ();
Place in a label:
myLabel.setText (theText);
One button listener:
myButton.addActionListener (New Executioner) {@ Override Public Action Perfid (Action Event Event) {String theText = myTextArea.getText (); MyLabel.setText (theText);}}); By looking at your edit, your problem is that by adding a component to your frame ( JFrame # modify it ()
).