gpt4 book ai didi

java - 单击时填充单元格

转载 作者:行者123 更新时间:2023-12-02 05:04:37 25 4
gpt4 key购买 nike

首先感谢您的支持。我正在使用 MySQL 数据库创建一个应用程序来存储用户详细信息(姓名、年龄......)。只是想将名称值发送到用户单击的 JTable 单元格。

我可以将值存储在字符串中,并在 System.out.println 中显示它,但无法用该值填充单元格。

这有可能吗?

最佳答案

I'm able to store the value in a String, and show it in System.out.println, but cannot fill the cell up with the value.

目前尚不清楚如何获取此字符串以及您尝试过什么,但您可以使用 setValueAt(...) 方法将此字符串设置为所选单元格的值。为了获取所选单元格的行和列索引,您应该分别使用 getSelectedRow()getSelectedColumn() 方法。最后要检测用户的“点击”,您必须附加 MouseListener到表或 ListSelectionListener到表的ListSelectionModel监听选择的变化。

查看API:

另请参阅:

关于java - 单击时填充单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27900925/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com