how to set focus to an AWT edit field?

L

lucy

Hi, I am desinging GUI,

Everytime I update the plot in axes window, the focus on the edit UI control
is lost.

How can I set focus back to this edit field control to let the user continue
his input?

Thank you,

-Lucy
 
C

carmine

lucy ha scritto:
Hi, I am desinging GUI,

Everytime I update the plot in axes window, the focus on the edit UI control
is lost.

How can I set focus back to this edit field control to let the user continue
his input?

Thank you,

-Lucy
u use a thread check if the focus is lost and re-assign the focus on the
object u want
 
L

lucy

carmine said:
lucy ha scritto:
u use a thread check if the focus is lost and re-assign the focus on the
object u want

That's exactly waht I was asking: how to re-assign the focus on the object I
want ?
 
A

ak

Everytime I update the plot in axes window, the focus on the edit UI
control

That's exactly waht I was asking: how to re-assign the focus on the object I
want ?
Component#requestFocus();
 
P

Paul Lutus

lucy wrote:

/ ...
That's exactly waht I was asking: how to re-assign the focus on the object
I want ?

Well, strictly speaking, you can't force the reassignment. But if you have
the desired object call requestFocus(), it will probably get focus in a
reasonable time.
 
A

ak

Everytime I update the plot in axes window, the focus on the edit UI
control
is lost.

How can I set focus back to this edit field control to let the user continue
his input?
the right question is - why you lost focus?
Post short compilable code, may be we'll find some mistake.
 
L

lucy

Paul Lutus said:
lucy wrote:

/ ...


Well, strictly speaking, you can't force the reassignment. But if you have
the desired object call requestFocus(), it will probably get focus in a
reasonable time.

requestFocus() refused my request and I did not get back my focus... this is
weired....
 
L

lucy

ak said:
the right question is - why you lost focus?
Post short compilable code, may be we'll find some mistake.

I am trying to do some "automatic" focusing for some other applications, not
written by me, but I need to focus on a edit control on it in order to save
some energy...
 
P

Paul Lutus

lucy wrote:

/ ...
Tried, no use....
requestFocus() refused my request and I did not get back my focus... this
is weired....

To get assistance, you need to post a small, complete, compilable code
example that shows the problem.
 
P

Paul Lutus

lucy wrote:

/ ...
requestFocus() refused my request and I did not get back my focus... this
is weired....

If you actually want assistance, post a short, complete, compilable example
that shows the problem.
 
A

ak

Component#requestFocus();
Tried, no use....
requestFocus() refused my request and I did not get back my focus... this is
weired....

this is simple - your request was not refused, the problem is that _after_
your request
focus gone because of some processing.
Try this form:

SwingUtilities.invokeLater(new Runnable() {
myComponent.requestFocus();
});
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,436
Messages
2,571,696
Members
48,796
Latest member
Greg L.
Top