Topic: 关于JTable的问题

  Print this page

1.关于JTable的问题 Copy to clipboard
Posted by: znotpig
Posted on: 2005-10-18 07:25

在JTable中setDefaultEditor为JTextField,当其中的一个grid处于编辑状态的时候,点击“保存“按钮,怎么样可以使正在修改的数据被接受到?

现在是只有在JTable上点击一下,使刚才的grid处于非编辑状态,数据才可以被接受。

谢谢大家!!!!!!

2.Re:关于JTable的问题 [Re: znotpig] Copy to clipboard
Posted by: chenjianguojt
Posted on: 2005-10-20 00:07

Component c = table.getEditorComponent();//获取当前正在编辑的grid

if (c != null) {
if (c.getClass().equals(JTextField.class)) {
( (JTextField) c).postActionEvent(); //发出编辑结束的事件,这样就可以在
//model中的setvalueat中获得数据了
}
}


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923