Author Topic: JTextArea getText funtion?  (Read 3511 times)

0 Members and 1 Guest are viewing this topic.

Offline Snake X

  • Ancient Veteran
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 810
  • Rating: +33/-8
    • View Profile
JTextArea getText funtion?
« on: June 06, 2011, 10:19:54 pm »
Ok, so If I have a JTextArea called input, and I want to make a string that comprises of what is inside the textbox (upon clicking a button via buttonListener), how can I do this?

String link = input.getText(); //something like this im sure.. though this isn't it.

^ thats pretty much what im trying to do
Loved this place, still the best producers of power metal, and sparked my dreams of coding.

Offline cooliojazz

  • Support Staff
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 619
  • Rating: +66/-9
  • I omnoms on your soul
    • View Profile
    • Unreal Phantasies
Re: JTextArea getText funtion?
« Reply #1 on: June 06, 2011, 11:48:22 pm »
Depenends on if you want the plain text or not.  If you want the actuall contents (EG html tags if it's type text/html , or rtf tags if it's text/rtf) or it's just type text/plain, just use input.getText(), if you're using any "rich" text format but you still just want the plain text, you can use input.getDocument().getText(0, input.getDocument().getLength());
Okay, I just wrote all that, then realized you said jtextarea, not jeditorpane or jtextpane, so everything i dsaid about rich text is inapplicable. =\ Anywasy, input.getText() is correct, why did you think it wasn't?
Spoiler For Random signess:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."

TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here | The Rest Should Be Here (Bandcamp)

Offline Snake X

  • Ancient Veteran
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 810
  • Rating: +33/-8
    • View Profile
Re: JTextArea getText funtion?
« Reply #2 on: June 08, 2011, 08:06:55 am »
because I had this and it didn't setText:

Code: [Select]
String link = input.getText();
output.setText(link);

There wasn't anything in the ouput JTextArea even though I put something in it
Loved this place, still the best producers of power metal, and sparked my dreams of coding.