Thanks Jeanette,
You are correct. I should be using "
table.getCellEditor().stopCellEditing()); ".
I get the point. Thanks for the clarification !
regards,
Ramana
----- Original Message -----
From: "Kleopatra" <[EMAIL PROTECTED]>
To: "Ramana TSV" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, December 24, 2002 4:54 PM
Subject: Re: JTable editing problem...
>
>
> Ramana TSV wrote:
> >
> > Well there is one more way....I prefer this, as its much simple!
> >
>
> [..]
>
> > FocusAdapter focusAdapter = new FocusAdapter() { // write a focus
listener
> > that trigger the stopCellEditing()
> > public void focusLost(FocusEvent e) {
> > myTable.getCellEditor(myTable.getEditingRow(),
> > myTable.getEditingColumn()).stopCellEditing();
> > }
> > };
>
> sorry, but that's totally wrong - there is no guarantee whatsoever
> that the editingRow/editingColumn is still valid at the time of a
> focusLost. Additionally, the method getCellEditor(row, column) is
> _not_ meant for being used while editing. It's meant to encapsulate
> the strategy for choosing an appropriate editor _before_ starting an
> edit.
>
> The correct code for terminating an edit (using the approach to force
> it in an focusListener is:
>
> if (table.isEditing())
> table.getCellEditor().stopCellEditing());
> }
>
> the if-check guarantees that getCellEditor returns the currently
> active editor != null which is the only one you are interested in.
> Note that at any time there is at most one editor active.
>
> If there is some validation involved the editor might refuse to commit
> the edited value by returning false from the stopCellEditing(). Then
> additional processing is needed, depending on how you want to react to
> that refusal - in 1.3 things are getting hairy then...
>
> Happy holidays
> Jeanette
>
>
> _______________________________________________
> Swing mailing list
> [EMAIL PROTECTED]
> http://eos.dk/mailman/listinfo/swing
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing