0

I'd like to insert a JPopupMenu for each cell of a column of my JTable (to be able to select multiple items). Any idea how to do that?

TzL
  • 13
  • 3

1 Answers1

2

For multiple selections within a cell, you'll need both a custom renderer and editor. For the editor component, use a JList with the selection mode set to MULTIPLE_INTERVAL_SELECTION. The renderer should display something appropriate for the content, e.g. a comma-separated list of values. Note that the data for each row must be stored in the TableModel, not in the renderer and editor itself. The details will depend on your data model, but List<String> or EnumSet<String> may be appropriate.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045