permaculture playing cards*
The moose likes Swing / AWT / SWT and the fly likes JTextArea and KeyEvent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextArea and KeyEvent" Watch "JTextArea and KeyEvent" New topic
Author

JTextArea and KeyEvent

mira yang
Ranch Hand

Joined: Nov 08, 2003
Posts: 33
The user put some words in the textArea,and send the message to he friends. i want to add a keylistener ,the code send the message to net when the user press "shift+enter+crtl" .how to do this?
Thanks!
Ben Zung
Ranch Hand

Joined: Mar 25, 2004
Posts: 109
Don't understand the question.
"shift+enter+crtl"

Why make it so complicated?
Bing
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Complicated key combination aside, what have you tried?
JTextArea text = new JTextArea();
text.addKeyListener(myKeyListener);
Have you even tried to do anything?


GenRocket - Experts at Building Test Data
mira yang
Ranch Hand

Joined: Nov 08, 2003
Posts: 33
"shift+enter+ctrl" means that when all of the three keys are pressed at the same time.
i try it this way but it does't do what i want:
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by mira yang:
"shift+enter+ctrl" means that when all of the three keys are pressed at the same time.
i try it this way but it does't do what i want:

Try
mira yang
Ranch Hand

Joined: Nov 08, 2003
Posts: 33
i tried it but it does't work.
is there anyother solution?
Ben Zung
Ranch Hand

Joined: Mar 25, 2004
Posts: 109
I am sorry I still don't see why you want the three key combo.
Without testing you may want to setup three booleans

And check the keyCode in keyPressed and then check the three booleans to do the trick.

HTH.
bing
mira yang
Ranch Hand

Joined: Nov 08, 2003
Posts: 33
Thanks ,i got it like this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextArea and KeyEvent