File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes How to override the TAB KeyEvent  functionality Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to override the TAB KeyEvent  functionality" Watch "How to override the TAB KeyEvent  functionality" New topic
Author

How to override the TAB KeyEvent functionality

Krishnamurthy Dara
Greenhorn

Joined: Jul 27, 2006
Posts: 7
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

Joined: Jun 09, 2003
Posts: 4632
> 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

Joined: Aug 03, 2006
Posts: 10
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to override the TAB KeyEvent functionality
 
Similar Threads
JSP with Tab feature
Handle shift+Tab key event
color in selected text in text area
Tab feature to JSP
Building JSP's with Tab feature