如何根据单击的行获取jtable的单元格值
我正在尝试在连接到数据库的 jtable 上使用更新方法,并希望根据用户单击的行填写表单上的文本字段。我知道我将需要 getValueAt() 方法,但是我不确定如何根据用户单击的行填写哪一行。我在谷歌上找不到任何东西,所以任何信息都会有帮助!
I am trying to use an update method on my jtable that's connected to the database and would like to fill in the textfields on the form depending on which row the users clicks. I understand I will be needing a getValueAt() method however I am uncertain of how to fill in which row depending on which row the user clicks. I am unable to find anything on Google or anything so any information would be helpful!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
干杯,
Cheers,
您将需要调用表模型的 getValueAt() 来获取所需的值。您还需要桌面上有一个侦听器来侦听选择。因此,一旦用户选择一行,您就可以调用 getValueAt() 来获取该行中特定数据列的值。
You will need to call getValueAt() your table's model to get the values you need. You will also need a listener on the table to listen for selections. So that once a user selects a row you call getValueAt() to get the value for the specific column of data in that row.