aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How can a TextField get focus? 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 can a TextField get focus?" Watch "How can a TextField get focus?" New topic
Author

How can a TextField get focus?

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
How can I let a text field get focus on it whenever it display?
How can I let this text field add a key strok ActionListener (Enter key) that mean when I type "Enter" key in this text field and some action will happen?
Please teach me. Thanks!
deekasha gunwant
Ranch Hand

Joined: May 06, 2000
Posts: 396
hi,
to get the focus to the textfield. use textfield.requestFocus();
and to respond to the enter key
- add keyListener to ur text field.
- in the keyReleased() method of ur key listener. just check
if(keyevnt.getKeyCode()==KeyEvent.VK_ENTER)
{
///enter key pressed do ......
}
else
{
///do nothing
}

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi deekasha gunwant:
Thank you very much! Moreover do you know How can I determine a database is empty or not, if it is not empty, how can I print out the names of all the tables currently existing in the database.
Thank you for your teach!
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
hi
u can quey the database by querying the system table "tabs" (i'm taking wrt Oracle) if result set is null then u can say that database was empty, and far as the problem of displaying column name is concerned u can query the same tabe for table_name column and display the result in either text area or table or whatever u wan't to use. but u see it depends a lot on the database u r using. i have written it wrt Oracle only. i don't know whether it will be helpful for u or not.
Naima Muzammal
NETSOL Intl.
Pakistan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can a TextField get focus?