• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to override the TAB KeyEvent functionality

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic