0

I'm trying to add JComboBox to JTable row.The table represents six groups( columns) with few characteristics( rows). I found many solutions for adding JComboBox to a column, but not to the specific row. Will appreciate any help. Attached code. All it does now, is to print JComboBox class name in the specific row:

JPanel panel = new JPanel();
panel.setLayout(new GridLayout(0, 7));
boolean DEBUG = false;
boolean ALLOW_COLUMN_SELECTION = false;
boolean ALLOW_ROW_SELECTION = true;
String[] values = {"256","64"};
JComboBox Combo = new JComboBox(values);
Combo.setEditable(true);
final String[] columnNames = {"","Group One","Group Two","Group Three","Group Four","Group Five","Group Six"};
final Object[][] data= {
        {"Row one:","","","","","",""},
        {"Row two:","","","","","",""},
        {"Row three:","","","","","",""},
        {"Row four",Combo,Combo,Combo,Combo,Combo,Combo},
        {"Power :","","","","","",""}
};
        final JTable table = new JTable(data, columnNames);
        table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
neverEugene
  • 69
  • 10
  • 1
    *"found many solutions for adding combobox to a column, but not to the specific row."* If it needs doing, that suggests the data is not tabular. Why the need to do so? – Andrew Thompson Oct 06 '14 at 12:30
  • Thank you, Andrew, for your answer. Why the data is not tabular? The choice of columns and rows based on convenience and history only. I can swap them, if there is no other solution. – neverEugene Oct 06 '14 at 12:40
  • *"..based on convenience.."* 1) It doesn't seem so convenient now. As soon as a table tries to become something more than a table it becomes messy. *"..and history"* 2) Perhaps it's time to change the approach. – Andrew Thompson Oct 06 '14 at 13:47
  • More related [examples](http://stackoverflow.com/search?q=user%3A131872+tablecomboboxbyrow). – trashgod Oct 06 '14 at 14:25

0 Answers0