import javax.swing.*; import javax.swing.table.*; import java.awt.*; import java.awt.event.*; public class TableRenderDemo extends JFrame { JLabel silt=new JLabel("kokku"); public TableRenderDemo() { super("TableRenderDemo"); getContentPane().add(silt,BorderLayout.SOUTH); MyTableModel myModel = new MyTableModel(); JTable table = new JTable(myModel); table.setPreferredScrollableViewportSize(new Dimension(500, 100)); JScrollPane scrollPane = new JScrollPane(table); for(int i=0;i<5;i++){ lisaCombo(table.getColumnModel().getColumn(i)); } getContentPane().add(scrollPane, BorderLayout.CENTER); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } public void lisaCombo(TableColumn tulp) { //Set up the editor for the sport cells. JComboBox comboBox = new JComboBox(); comboBox.addItem("O"); comboBox.addItem("X"); tulp.setCellEditor(new DefaultCellEditor(comboBox)); } class MyTableModel extends AbstractTableModel { final String[] columnNames = {"AAA", "BBB","CCC","DDD","EEE"}; final Object[][] data = { {"X", "O", "X", "O", "X"}, {"X", "O", "X", "O", "X"}, {"X", "O", "X", "O", "X"}, {"X", "O", "X", "O", "X"}, {"X", "O", "X", "O", "X"} }; public int getColumnCount() { return columnNames.length; } public int getRowCount() { return data.length; } public String getColumnName(int col) { return columnNames[col]; } public Object getValueAt(int row, int col) { return data[row][col]; } public Class getColumnClass(int c) { return getValueAt(0, c).getClass(); } public boolean isCellEditable(int row, int col) { return true; } public void setValueAt(Object value, int row, int col) { data[row][col] = value; int xkokku=0; for(int i=0;i