0

The issue I'm having is every time I try to add the combobox to the jtable text just pops up without the actual jComboBox & not the text from the JComboBox

jTable1 = new javax.swing.JTable();
JComboBox comboBox = new JComboBox();
comboBox.addItem("baby");
comboBox.addItem("new");
comboBox.setEditable(true);
jTable1.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {
        {"Opportunity Assessment", null, comboBox, null, null},
        {"IP Selection", null, null, null, null},
        {"Value Proposition Canvas Suite", null, null, null, null},
        {"Business Model Canvas", null, null, null, null},
        {"Market Opportunity Navigator", null, null, null, null},
        {"Porters 5 Forces-CSF", null, null, null, null},
        {"100 Customer Interviews", null, null, null, null},
        {"1000 Customer Surveys Complete", null, null, null, null},
        {"Minimum Viable Product", null, null, null, null},
        {"Competitive Advantage Chart", null, null, null, null},
        {"Go-to-Market Board", null, null, null, null},
        {"Financial Forecast-Link to Financials", null, null, null, null},
        {"Risk Analysis", null, null, null, null},
        {"Capital Needs-Link to Cap", null, null, null, null}
    },
    new String [] {
        "Tasks", "Status", "Results", "Insights", "Decision"
    }
));
jTable1.setEnabled(false);
jTable1.add(comboBox);
jScrollPane1.setViewportView(jTable1);
camickr
  • 321,443
  • 19
  • 166
  • 288
JLong
  • 85
  • 1
  • 9

2 Answers2

1

I figured it out I forgot to add a line that can access the column then add the combobox

jTable1.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(comboBox));
Dharman
  • 30,962
  • 25
  • 85
  • 135
JLong
  • 85
  • 1
  • 9
1

This topic was asked 7 years ago, It will probably be helpful to you. Link:

Adding JComboBox to a JTable cell