简体   繁体   English

在JTable中自动从特定列(即不必选择行)获取所有ID

[英]Getting all the ID's from a specific column automatically (i.e. not having to select a row) in a JTable

I would like,as the title suggests, to be able to get all the values in an ID column from a JTable without the user actually selecting a row (and thus ID).Lets say there are two results in the JTable, that means there are two items in the ID column. 正如标题所示,我希望能够从JTable中获取ID列中的所有值,而无需用户实际选择一行(并因此选择ID)。假设JTable中有两个结果,那意味着是ID列中的两项。 Is there a way that I extract these values automatically. 有没有一种方法可以自动提取这些值。

Much depends on your goal, but you can 在很大程度上取决于您的目标,但是您可以

  • Traverse the TableModel , invoking getColumnClass() for each column; 遍历TableModel ,为每列调用getColumnClass() use getValueAt() to examine the value for a particular row. 使用getValueAt()检查特定行的值。

     DefaultTableModel model = new DefaultTableModel(); … for (int col = 0; col < model.getColumnCount(); col++) { Class type = model.getColumnClass(col); } 
  • Use the methods of DatabaseMetaData & ResultSetMetaData to get the details of a relation's attributes, before inserting the data into the TableModel . 将数据插入TableModel 之前 ,使用DatabaseMetaDataResultSetMetaData的方法ResultSetMetaData关系属性的详细信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 只有特定的列可选择 JTable 和/或仅从一列获取数据 - Having only specific column selectable JTable and/or getting the data from only one column 从JTable的第一列获取名称行 - Getting a row of names from the first column of JTable JTable 获取特定列的值 - JTable getting values of specific column 将jtable列设置为image按钮,但动态更改特定行/列上的图像,而不是列中的所有行 - Set jtable column to image button, but dynamically change image on specific row/column, not all rows in column 我们可以用大小不同的其他行(即新字符串)替换文件中的行吗? - Can we replace a line from file with other line (i.e. new string) having different size? 如何从SQLite列中选择所有特定日期? - How do I select all specific days from a SQLite column? JTable 错误:我试图在文本字段中显示来自 JTable 的选定行值,但我不断收到此错误: - JTable error: I'm trying to display the selected row values from a JTable in the textfield but I keep getting this error: 从txt文件获取数据并将其添加到JTable时,如何对哪些数据进入哪一列或哪一行进行排序 - How do I sort what data goes in which column or row when getting data from txt file and adding it to JTable 更改JTable行中特定单词的颜色 - Change the specific word's color in the row JTable 在平板电脑上自动更新 Android App(即没有市场!) - Automatically update Android App on Tablet (i.e. without Market!)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM