简体   繁体   中英

JTable getting values of specific column

How could I get the values under specific column in JTable

example :

_________________________
| Column 1  | Column 2  |
________________________
|     1     | a         |
________________________
|     2     | b         |
________________________
|     3     | c         |
_________________________

How could I get the values under Column 1 that is [1, 2, 3] In the form of some data structure ( preferable array)?

you can do something like this

ArrayList list = new ArrayList();
for(int i = 0;i<table.getModel().getRowCount();i++)
{
    list.add(table.getModel().getValueAt(i,0)); //get the all row values at column index 0
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM