Search code examples
javaswingjtabletablemodeltablecelleditor

How to store multiple values in a JTable row as a JCombobox


Hashmap contains key and value(result of parsing an XML). Hashmap contains things in the way that key is a string and value is a vector. A key may have single value in the vector or mutiple values in the vector.

My question is:

This hashmap, has to be put into a jtable,such that if the key has single value, put it to text box. If it has multiple values insert a combobox in the row of that table.

I need the swing code for this problem


Solution

  • Not code but steps that can help you..

    1. Create a Table.
    2. Every time adding a new row check for the hashmap value and if it is a single value add textbox to that cell or add comboBox.
    3. Repeat step 2 for all hashmap keys.

    References that can help you:-

    1. Adding row in table
    2. Adding comboBox in table
    3. JTable add/remove rows to custom table model (updating table display)