Redian新闻
>
求教 Listenser for table in Java
avatar
求教 Listenser for table in Java# Java - 爪哇娇娃
l*r
1
I have a button and a JTable. I want to set button to enable if user type or
change content one row in table. Which listenser should I use? I implement
KeyTyped in table but it doesn't work.
Thanks!
avatar
s*m
2
May be you can try to look at TableModelListener interface. You may be able to
capture the event in tableChanged interface method.

【在 l***r 的大作中提到】
: I have a button and a JTable. I want to set button to enable if user type or
: change content one row in table. Which listenser should I use? I implement
: KeyTyped in table but it doesn't work.
: Thanks!

avatar
h*b
3
myJTable.addMouseListener(myMouseListener);
.....
//inner class
class myMouseListener extends MouseAdapter(MouseEvent e){
public void mouseClicked(MouseEvent e){
if(myJTable.getSelectedRow() != -1) myButton.setEnabled(true);
}
}
this should work, but check my typings, in a hurry, hehe!
Good luck!
Haibo

to
or

【在 s***m 的大作中提到】
: May be you can try to look at TableModelListener interface. You may be able to
: capture the event in tableChanged interface method.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。