Java JTable获取所选行的数据 [英] Java JTable getting the data of the selected row

查看:1084
本文介绍了Java JTable获取所选行的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有方法用于获取所选行的数据?我只想简单地点击包含数据的特定行,然后单击一个按钮,该按钮将在控制台中打印数据。

Are there any methods that are used to get the data of the selected row? I just want to simply click a specific row with data on it and click a button that will print the data in the Console.

推荐答案

快速谷歌会给你多个链接,里面有答案。尽管如此,您应该阅读本页:

A quick google would've given you multiple links with answers in it. Nonetheless, you should read this page:

http://docs.oracle.com/javase/7/docs/api/javax/swing/JTable.html

你会在其中找到这些方法:

You will find these methods in it:

getValueAt(int row, int column)
getSelectedRow()
getSelectedColumn()

使用这些组合来实现结果。

Use a mix of these to achieve your result.

这篇关于Java JTable获取所选行的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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