File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Focus Gained event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply locked New topic

Focus Gained event

John Fernandas

Joined: Dec 15, 2011
Posts: 3
hi all,

I am having 4 Jtext fields in java swing frame the problem is i have to move the focus from one textfield to other text field
if the curser moves from one text to the other the text in that field need to be selected i dont know how to do this so give me the proper coding associate with this issue

Thanks in advance
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Moving to the Swing forum...
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> so give me the proper coding associate with this issue

these are the steps:

1) take your feet off the desk
2) open the apidocs for JTextField
3) read all the methods, including those inherited

you'll find what you seek.
Ranganathan Kaliyur Mannar

Joined: Oct 16, 2003
Posts: 1101

Welcome to the Ranch!

And, you have partially answered the question yourself. You need to write a FocusListener through the focusGained method:
The tutorial is the best place to start.

Darryl Burke

Joined: May 03, 2008
Posts: 5115

Continued here:

I'm locking this thread.

luck, db
There are no new questions, but there may be new answers.
I agree. Here's the link:
subject: Focus Gained event
It's not a secret anymore!