Article View: borland.public.jbuilder.java.swing
Article #13016Re: How to update last row's column in JTable?
From: Tapio Holopainen
Date: Wed, 07 Oct 1998 00:00
Date: Wed, 07 Oct 1998 00:00
34 lines
1629 bytes
1629 bytes
Thanks for your answer Vladimir.
I tried to your example, but I'm sorry to say that it didn't work...
TableModel's setValueAt-method was still not called at LAST row after
pressing enter.
Then I tried different approach to problem and 'invent' a workaround
(which I think is NO good solution, but it works!).
This is what I did:
I put following KeyAdapter to my table (extending from JTable)
KeyAdapter adapter = new KeyAdapter()
{
public void keyPressed(KeyEvent e)
{
if(e.getKeyCode() == KeyEvent.VK_ENTER
&& _table.getEditingRow() == _table.getRowCount()-1)
{
int editRow = _table.getEditingRow();
int editCol = _table.getEditingColumn();
_table.getModel().setValueAt(_table.getCellEditor(editRow,editCol).getCellEditorValue(),editRow,editCol);
}
}
};
_table.addKeyListener(adapter);
If you (or anyone) have better ideas to this problem I would be very
happy to forget this 'solution' :)
Cheers,
- Tapio
Technical Details
Message-ID:
<361B2E0C.E49346AD@sysline.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3619C83F.6F23ED4A@sysline.com> <361AAA9C.6BA736E3@collegemail.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,75b4b6d81fb5a685 X-Google-Attributes: gid111d45,public From: Tapio Holopainen <tapio.holopainen@sysline.com> Subject: Re: How to update last row's column in JTable? Date: 1998/10/07 Message-ID: <361B2E0C.E49346AD@sysline.com> X-Deja-AN: 398561940 Content-Transfer-Encoding: 7bit References: <3619C83F.6F23ED4A@sysline.com> <361AAA9C.6BA736E3@collegemail.com> To: Vladimir Olenin <keenonjava@collegemail.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Sysline Oy Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing