• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

KeyListener && KeyEvents

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,
My problem had two various things.

1-
I wanna dedect when tab key is pressed or typed or released.
i tried ;

I dont even get the first message when i type tab key.
Its moving to another focusable component and seems No Keyevent fired.

How can i dedect if tabkey is typed?

2-When its typed i want it's function not to be performed.
I mean it should not go to next focusable field.
But i want to dedect it when its typed.Because i want to make some operations suc as jdbc and after that either i am going to send the cursor to next focusable field or another one or in case of failure of a select sql , i wont permit the user pass the field which is tabkey pressed.

User must not move to another field without entering a valid value that is existing in db table..

thank you.
[ February 23, 2006: Message edited by: sinasi susam ]
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you want the contents of a field to be verified when the user tries to shift focus off that field. That is a job for InputVerifier. Since focus management grabs tab key events they never make it to the text field. And as a rule of thumb I suggest that you shouldn't write KeyListeners -- they are almost always wrong, or there is a better solution not involving them.
 
sinasi susam
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for answer.
However How can i manage the focusing after the textfield is verified?
Cursor is moving to next focusable component.
I also want to manage its movement.And some other operations..

I imagine it to be like this,

User is going to hit the tab key, and secondly it will connect to an application server.App. server is going to run an sql statement and will return the results in form of text documents such as ;

focus [component_name]
visible [component_name]
enable[component_name]
or
setValue[component_name,value]

And after that i will get the results and process with a parser..
If not any movement exists cursor will not go anywhere either..

its like this..

[ February 23, 2006: Message edited by: sinasi susam ]
[ February 23, 2006: Message edited by: sinasi susam ]
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see if this gets you what you want

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to implement KeyLitener interface and implement the overridden methods void keyTyped(), void keyPressed(), void keyRelease() methods
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!