AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

On focuslost ()

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
Suchitra
Guest





PostPosted: Fri Nov 26, 2004 3:05 pm    Post subject: On focuslost () Reply with quote



Hi there!
I'm stuck on a technical difficulty while I was implementing the
validation logic for quite a few days.

My validation logic is invoked on focuslost event of an editable combo.
There are Ok and Apply button on the dialog will save the setting in a
file.

Now, if I edit the combo setting and then immediately click
the OK button.
The very first event called is the FocusLost after which it
should ideally work on the enqueued event which actually caused it. But it
doesn't call my OK button handler.
I have to again press an click to save it.

Why does it focuslost event eat the ACtionEVent ?
Is there any work-around for this ?

I'll appreciate any kind of help.
Thanks

Back to top
John McGrath
Guest





PostPosted: Sat Nov 27, 2004 8:58 am    Post subject: Re: On focuslost () Reply with quote



On 11/26/2004 at 10:05:37 AM, Suchitra wrote:

Quote:
I'm stuck on a technical difficulty while I was implementing the
validation logic for quite a few days.

My validation logic is invoked on focuslost event of an editable combo.

Have you tried using an InputVerifier?

--
Regards,

John McGrath

Back to top
Suchitra
Guest





PostPosted: Mon Nov 29, 2004 4:56 am    Post subject: Re: On focuslost () Reply with quote



Nopes. Can you explain something more about this ?

Back to top
Suchitra
Guest





PostPosted: Mon Nov 29, 2004 5:10 am    Post subject: Re: On focuslost () Reply with quote

Actually, problem is because the validation logic is happening
on the server side and hence spawned on a different worker thread.

My Event-Dispatch thread needs to wait till this thread returns back as it
can't save the settings till then.

Some pointers would really help.
Thanks



Back to top
Andrew Thompson
Guest





PostPosted: Mon Nov 29, 2004 5:12 am    Post subject: Re: On focuslost () Reply with quote

On Sun, 28 Nov 2004 23:56:53 -0500, Suchitra wrote:

Quote:
Nopes. Can you explain something more about this ?

<http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/InputVerifier.html>

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane

Back to top
Babu Kalakrishnan
Guest





PostPosted: Mon Nov 29, 2004 7:53 am    Post subject: Re: On focuslost () Reply with quote

Suchitra wrote:
Quote:
I'm stuck on a technical difficulty while I was implementing the
validation logic for quite a few days.

My validation logic is invoked on focuslost event of an editable combo.
There are Ok and Apply button on the dialog will save the setting in a
file.

Now, if I edit the combo setting and then immediately click
the OK button.
The very first event called is the FocusLost after which it
should ideally work on the enqueued event which actually caused it. But it
doesn't call my OK button handler.
I have to again press an click to save it.

Why does it focuslost event eat the ACtionEVent ?
Is there any work-around for this ?


I find this hard to believe. Are you sure you aren't getting the
ActionEvent from the button ? (Try just putting in some debug println
statements in the focuslost as well as the ActionEvent handler).

If you're certain you're "losing" the actionevent, please post a code
sample that exhibits this behaviour - I'm sure it has to do with
something you're doing in your focus handler.

And as a general rule of thumb, performing validation in a focusLost
handler is generally trouble-prone. Try looking at an InputVerifier as
another poster suggested. (though I vaguely recall some discussion about
even InputVerifiers not behaving too well in complex components such as
a ComboBox : I've never used one on a JComboBox - so cannot offer any
feedback on how well it works)

BK

Back to top
John McGrath
Guest





PostPosted: Tue Nov 30, 2004 4:44 am    Post subject: Re: On focuslost () Reply with quote

On 11/28/2004 at 11:56:53 PM, Suchitra wrote:

Quote:
Nopes. Can you explain something more about this ?

javax.swing.InutVerifier.

Check the Sun site for more information. InputVerifier is covered in the
Java Tutorial, and one of the sample chapters for a Swing book posted
there covers the subject in detail.

--
Regards,

John McGrath

Back to top
John McGrath
Guest





PostPosted: Tue Nov 30, 2004 5:01 am    Post subject: Re: On focuslost () Reply with quote

On 11/29/2004 at 12:10:32 AM, Suchitra wrote:

Quote:
Actually, problem is because the validation logic is happening
on the server side and hence spawned on a different worker thread.

That sounds like a very different problem than what you described in your
previous message. But it certainly does present some challenges.

If you need to connect to a server to do some part of the validation, you
do not want to do that at the field level, at least not synchronously.
That would slow things down and it would freeze the UI if you have some
sort of network slowdown or failure.

The easiest solution would be to do these validations at the form level.
When the user presses OK or whatever he does to commit the changes, you
would then do the server-based validations. As an alternative, you could
do these in a background thread and use some sort of indicator in the UI,
such as changing the text color to red, to indicate errors in the values.

Quote:
My Event-Dispatch thread needs to wait till this thread returns back as
it can't save the settings till then.

No, you do not want the Event Dispatch Thread waiting on any process that
is not guarateed to complete quickly. You should consider your validation
to be a "long-running process", so you need to do the validation in a
separate thread.

--
Regards,

John McGrath

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.