简体   繁体   中英

java swing: how to create dynamically columnizing table?

How would you go about creating a java swing table, which automatically creates a new column whenever a column item is added ?

For example, adding "Id", would intially add a Id column table. adding "title" would add "title" column table.

any examples or library that can handle this already ? Also, how would you also display an image inside the table ?

For example, adding "Id", would intially add a Id column table.

Check out the addColumn(...) method of the DefaultTableModel.

Also, how would you also display an image inside the table ?

Override the getColumnClass() method of the JTable or the TableModel to return Icon for the appropriate column and the table will use the Icon renderer. Then you add an Icon to the TableModel for that column.

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