[英]How to get a value from JTable 1 to JTable 2?
I have no idea how to pass a value from jtable1
to jtable2
. 我不知道如何将值从
jtable1
到jtable2
。 For an example, When I double-click the row from jtable1
, and it will display the same value at jtable2
. 例如,当我双击
jtable1
,它将在jtable2
显示相同的值。 Any idea? 任何想法? I think hard for a long time, and I can't solve the problem.
我想了很长时间,但我解决不了这个问题。
If you want to transfer value from one jTable
to another jTable
within the same JFrame, in the mouse click event of jTable1
give 如果要将值从一个
jTable
转移到同一JFrame中的另一个jTable
,请在jTable1
的鼠标单击事件中给出
jTable2.setValueAt(jTable1.getValueAt(0, 0).toString(), 0, 0);
jTable2.setValueAt(jTable1.getValueAt(0, 1).toString(), 0, 1);
jTable2.setValueAt(jTable1.getValueAt(0, 2).toString(), 0, 2);
Hope this will resolve your problem... 希望这能解决您的问题...
Study the tutorial section How to Use Tables: User Selections and learn how to How to Write a List Selection Listener . 学习教程部分如何使用表:用户选择,并学习如何编写列表选择监听器 。 In your
jtable1
listener, you can update the TableModel
of jtable2
to display any related data. 在
jtable1
侦听器中,您可以更新jtable2
的TableModel
以显示任何相关数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.