Vetoing a change by DefaultCellEditor in JTable

Discussion in 'Java' started by Brian J. Sayatovic, Aug 27, 2003.

  1. I'm using a DefaultCellEditor with a JTextField to capture a String
    that is ultimately passed to setValueAt in my TableModel. In that
    method, I have logic which could throw an exception if the String's
    contents proves to be invalid (i.e. one use is where the String is a
    regular expression that might be syntactically invalid).

    How can I handle this? Right now, the code throws an Exception which
    I'd like to catch, display a dialog, and then return the user to
    editing without ever committing the value. Is this easily doable?

    Regards,
    Brian.
    Brian J. Sayatovic, Aug 27, 2003
    #1
    1. Advertising

  2. (Brian J. Sayatovic) writes:

    > How can I handle this? Right now, the code throws an Exception which
    > I'd like to catch, display a dialog, and then return the user to
    > editing without ever committing the value. Is this easily doable?


    Override the TableModel's stopCellEditing() to catch the exception and
    return false, otherwise return true.
    Tor Iver Wilhelmsen, Aug 27, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tivo Escobar
    Replies:
    1
    Views:
    7,259
    manusa
    Apr 12, 2007
  2. oulan bator
    Replies:
    7
    Views:
    562
    oulan bator
    Dec 20, 2005
  3. michael.o'
    Replies:
    9
    Views:
    11,705
    bparanj
    May 30, 2006
  4. Tintin92
    Replies:
    1
    Views:
    1,672
    Andrew Thompson
    Feb 14, 2007
  5. JoeyB
    Replies:
    4
    Views:
    636
    John B. Matthews
    Jul 25, 2009
Loading...

Share This Page