Anand,

I should have given more information. The dialog has a panel which
has different data editors depending on how it is invoked. In some
cases, the panel may not even have a table. In short, dialog doesnot
have an idea of what is being edited. In some cases, its JTable,
in some cases its just a JTextField or it could anything else.

If I make OK button to find out what it is, I am making dialog
sensitive to data editor instance which I wanted to avoid because
its a not a good bean design pattern.

let me know if there is any other way out.

Also I have noticed that if I set a cell editor on a table, then
I can start editing cell, either by single clicking or double clicking.
BUUUT...surprisngly enough ONLY when I double click, I see my
JTextField
table cell renderer otherwise for single click JTable renders something
else than what I set !!!!!!!!!!!! ( My cell renderer which is a
JTextField has some properties set so that it looks good when user
starts editing )

Any idea whats going on here ?

rgds
Peter


--- Anand Hariharan <[EMAIL PROTECTED]> wrote:
> Hi Peter :
> 
> We had the same problem and this is how we handle it :
> 
> Consider m_EditTable as the table that is being currently edited. 
> Execute this code when OK is clicked.
> 
> 
> if(m_Table.isEditing())
> {
>     Component c = m_Table.getEditorComponent();
>     if(c != null)
>     {
>         String val = "";
>         if(c instanceof JTextField)
>             val = ((JTextField)c).getText();
>         /*else if( c instanceof SomeOtherComponent )
>             val = (String) GetStringValueFromComponent;*/
>         m_Table.getModel().setValueAt (val, m_Table.getEditingRow(), 
> m_Table.getEditingColumn());
> 
>         m_Table.removeEditor();
>     }
> }
> 
> Regards,
> _anand
> [EMAIL PROTECTED]
> 
> http://www.javareference.com (Articles/Examples and more !)
> 
> 
> 
> ----- Original Message ----- 
> From: "Peter Peterson" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, December 19, 2002 9:41 AM
> Subject: JTable editing problem...
> 
> 
> > Hi,
> > 
> > I have a JDialog which has OK/Cancel button. When user clicks
> > on any of these buttons, dialog goes away ( setVisible(false) ).
> > 
> > This dialog has an editable JTable. I am using a JTextField
> > as a cell editor because I wanted to capture focusLost event
> > on a cell. 
> > 
> > Now the problem is that AFTER entering value in any cell
> > AND WITHOUT hiting Enter/Tab, if user clicks on OK/Cancel button,
> > the focus lost event is not getting called consitantly. Looks like
> > sometime, actionListener on ok/cancel buttons kicks in and
> sometimes
> > focusListener on cell kicks in. ( Note that to save new entered
> value
> > in table model, user must either hit enter or tab out so that
> > setValueAt gets called. )
> > 
> > does any one know how to handle this properly ?
> > 
> > 
> > rgds,
> > Peter
> > 
> > 
> > __________________________________________________
> > Do you Yahoo!?
> > New DSL Internet Access from SBC & Yahoo!
> > http://sbc.yahoo.com
> > _______________________________________________
> > Swing mailing list
> > [EMAIL PROTECTED]
> > http://eos.dk/mailman/listinfo/swing
> > 
> 


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing

Reply via email to