Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextArea and KeyEvent

 
mira yang
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't understand the question.
"shift+enter+crtl"

Why make it so complicated?
Bing
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Complicated key combination aside, what have you tried?
JTextArea text = new JTextArea();
text.addKeyListener(myKeyListener);
Have you even tried to do anything?
 
mira yang
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried it but it does't work.
is there anyother solution?
 
Ben Zung
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ,i got it like this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic