• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to override the TAB KeyEvent functionality

 
Krishnamurthy Dara
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

In applets, I have one TextArea.In that I need to override the Tab key functionality with select all content in that text area.

If you press the tab it should select all the content which text area has.

Here I add keylistener to textarea, I am writing like this

public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_TAB) {
textArea.selectAll();
}
}
Then KeyTyped and KeyPressed I didnot write any thing. Here I am getting selection for all content but, in second tab hit the content is replace with empty value.

How to overcome this issue..

Regards,
Krishna
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Here I am getting selection for all content but, in second tab hit the
> content is replace with empty value.

sounds correct to me, what do you want to happen?
 
Kirill Grouchnikov
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you're not removing the existing listener, the second Tab hit is processed by it. Since the first Tab hit has selected all the text, the existing listener just replaces the current selection with Tab symbol.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic