aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTextArea question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextArea question " Watch "JTextArea question " New topic
Author

JTextArea question

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
Hi guys,

I wonder if there's anyway to (1) press a button (say ctrl-t) and the JtextArea will write a the NAME of the user (NAME=some string prepared in advance).

Currently I have it with a jbutton - but when the user press this button, the NAME is *append* to the jtextArea and not (2) getting in the right place (where the cursor is located).

any idea?

Thanks
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
You can bind these keys and the corresponding Action to the JTextArea or one of its parent JComponents. The How to Use Key Bindings page in the tutorial shows how to do this.

JTextArea has an insert method that may be useful for adding the name. Also, its superclass JTextComponent has handy methods for moving around in a JTextArea. You can find the JTextComponent methods that apply to JTextArea in the Methods inherited from class javax.swing.text.JTextComponent section of the JTextArea api.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextArea question
 
Similar Threads
JRadioButtons in applet
JButtons
Back end validation problem .
Urgent: Submitting a form in a page and using it's values in an already open page
JSP throwing null pointer exception the first time I run it