Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to set focusing next component after hitting enter key  RSS feed

 
vinoth sathiyamoorthy
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

i write a appllication for billing.

four text boxes are available.

after enter some value in jTextField1, cursor focused to next jTextField2 after enter key pressed.

i tried transferFocus() method but didnt work.

please help me.


with hope.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JTextFields already have a key binding for Enter which triggers an ActionEvent. Use addActionListener to listen to these.
 
vinoth sathiyamoorthy
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for ypur help.

one doubt i have set nextFocusableComponent to jButton1.

after enter some value from jTextField4 it focus to jButton1.but when i hit enter jButton1 doesnot work.only mouse click action worked.keyboard enter not supporting. what is the problem?

With hope.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JButtons don't have a key binding for Enter, only for Space (as far as I know). So please follow the link Maneesh has given.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!