Всем спасибо. Решение найдено:
| Код |
int col = -1; int row = -1; JTable tabelle;
public static void main(String[] args) { test t = new test(); t.setSize(500,200); t.setLocation(300,300); t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); t.setVisible(true);
} public test() { super("Table"); tabelle = new JTable(3, 3); JScrollPane pane = new JScrollPane(tabelle); JPanel panel = new JPanel(); JComboBox cb =new JComboBox(); tabelle.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(cb)); tabelle.addMouseMotionListener(new MouseAdapter() { @Override public void mouseMoved(MouseEvent e) { col = tabelle.columnAtPoint(e.getPoint()); row = tabelle.rowAtPoint(e.getPoint()); if(col == 1) tabelle.editCellAt(row, col); else if(tabelle.getCellEditor() != null ) tabelle.getCellEditor().stopCellEditing(); } }); cb.addMouseListener(new MouseAdapter() { @Override public void mouseExited(MouseEvent arg0) { if(tabelle.getCellEditor() != null ) { SwingUtilities.invokeLater(new Runnable() { public void run() { tabelle.getCellEditor().stopCellEditing(); } }); } super.mouseExited(arg0); } });
panel.add(pane); setContentPane(panel); }
}
|
Добавлено через 14 минут и 17 секунд забыла пометить вопрос, как решенный. |