Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JButton, JTextArea, and JTextField  RSS feed

 
Suela Smith
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone

I got a JButton, JTextField, and JTextArea. I want to add the text from JTextField to JTextArea, and all this to happen when i click the JButton


thanks in advance for any help
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Attach an ActionListener to the button. In the actionPerformed() method of that listener, use getText() on the JTextField to get the text, and setText() on the JTextArea to set it.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
...and setText() on the JTextArea to set it.


Or append() if you want to append to the Text Area.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!