I can’t say what went wrong. But I changed my code a bit (as it had compile-time errors)
It works great for me. Below is a screenshot

public class Item{
String itemDesc = "";
float price = 0;
Object[][] data = {{"test","test","test"},
{"test","test","test"},
{"test","test","test"},
{"test","test","test"}};
}
Your main table class
package test;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Menu;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.TableColumn;
public class Table extends JFrame
{
private JPanel topPanel;
private JTable table;
private JScrollPane scrollPane;
private JButton update_Button;
public Table() {
setTitle("Add new item");
setSize(300, 200);
setBackground(Color.gray);
topPanel = new JPanel();
topPanel.setLayout(new BorderLayout());
getContentPane().add(topPanel);
String columnNames[] = { "Item Description", "Item Type", "Item Price" };
Object dataValues[][];
Item itm = new Item();
dataValues = itm.data;
table = new JTable(dataValues, columnNames);
JComboBox itemTypeCombobox = new JComboBox();
TableColumn column1 = table.getColumnModel().getColumn(1);
column1.setCellEditor(new DefaultCellEditor(itemTypeCombobox));
scrollPane = new JScrollPane(table);
topPanel.add(scrollPane, BorderLayout.CENTER);
JButton button = new JButton("Add Item");
topPanel.add(button, BorderLayout.SOUTH);
}
public static void main(String[] args) {
Menu m = new Menu();
Table mainFrame = new Table();
mainFrame.setVisible(true);
}
}
source
share