• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

How to implement JTextArea in netbeans

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, perhaps I'm confused here. I have dragged and dropped a jTextArea from netbeans palette onto my form. But when I right clicked for Event > action > actionPerformed for implementation, I realized such was not there, unlike the jTextField component. Could someone educate me on how to achieve this? For example, I have tried this but it didn't work:

//{
Import java.swing.*;

JTextArea txa = new JTextArea();
txa.getText(jTextArea1);
txa.setText(jTextArea1);
txa.setTextWrap(true);

//}
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to get the Document and add a listener to that.
May I suggest you read the Java tutorial on using JTextArea http://docs.oracle.com/javase/tutorial/uiswing/components/textarea.html which explains all about this.
 
Rancher
Posts: 3052
22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ActionListener of a JTextField is invoked when you use the Enter key.

A JTextArea does not support the same concept. When you use the Enter key on a JTextArea a new line string is inserted into the Document.

If you tell us your actual requirement then we may be able to suggest a solution for you.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!