Re: handling focusLost Events

From: Paul Lutus (nospam_at_nosite.zzz)
Date: 10/21/03

  • Next message: rabbits77: "Odd character when retrieving a string from a HashMap"
    Date: Tue, 21 Oct 2003 11:36:04 -0700
    
    

    Nuggy wrote:

    > Ok, I'm ready to toss this thing across the room. Here's what I'm
    > trying to accomplish, greatly simplified:
    >
    > I have a screen with several text fields. I want to validate the
    > entry in each text field when the user tabs out of it to the next one
    > (some fields are required). If they enter an invalid entry or leave
    > it blank, I want to display a pop-up in the form of a
    > JOptionPane.showMessageDialog to inform them of the problem, then
    > reset focus to the invalid field.
    >
    > Here's the problem: fields a, b, and c are all validated this way,
    > and are sequential in the focus order. In a new screen, if the user
    > enters an invalid value into field a, field b briefly gets the focus
    > from the tab key, and in the course of popping up the box and
    > resetting focus to field a, field b loses this brief focus, gets
    > validated because of this, and I end up with two and sometimes three
    > pop-up boxes that I don't want. I am using isTemporary(); without it
    > I end up in an infinite loop of popups.

    Classic deadlock error. Create a flag that prevents this. If you see the
    need to create a validation dialog, first set a "busy" flag, then show the
    dialog. In your event handler code, first test the flag, if it is set, do
    nothing.

    Once the dialog is dismissed and the focus has been reset to the previous
    field, then clear the flag. This allows the event handlers to function
    normally again.

    > I've spent two days trying ideas and I'm still plagued by these
    > "phantom" popups.

    All you have to do is think it through. Your event handlers think any
    focus-lost event is equal to any other. But they are not the same -- some
    are initiated by the user, and some by your dialog.

    -- 
    Paul Lutus
    http://www.arachnoid.com
    

  • Next message: rabbits77: "Odd character when retrieving a string from a HashMap"

    Relevant Pages

    • Re: handling focusLost Events
      ... I want to validate the ... If they enter an invalid entry or leave ... Create a flag that prevents this. ... This allows the event handlers to function ...
      (comp.lang.java.programmer)
    • Re: handling focusLost Events
      ... I want to validate the ... If they enter an invalid entry or leave ... Create a flag that prevents this. ... This allows the event handlers to function ...
      (comp.lang.java.help)
    • Re: handling focusLost Events
      ... I want to validate the ... If they enter an invalid entry or leave ... Create a flag that prevents this. ... This allows the event handlers to function ...
      (comp.lang.java)
    • Re: Make Table Query and setting Number type
      ... I was trying to validate teh data in the temporary table (the one that I am ... > append it weekly. ... >>the entry table each time with a query that would give me the last entry ... >>that I may have to work on doing this through vba, ...
      (microsoft.public.access.queries)
    • Re: Newby TK Sanity check tracking Entry widget from HLL (Lisp, in fact)
      ... But one question has gone unanswered: is this the only way to get notified by Tk of every change to the entry value /during editing/, ie, before they exit the field? ... I have a textVariable associated with the widget, but I am not sure that helps. ... One note to make here is that by using validate -key this will capture ... Another option you have is setting a write trace on the variable associated ...
      (comp.lang.tcl)