如何根据单击的行获取jtable的单元格值 [英] How to get cell value of jtable depending on which row is clicked

查看:847
本文介绍了如何根据单击的行获取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!

推荐答案

你需要调用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.

这篇关于如何根据单击的行获取jtable的单元格值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆