日期:2014-05-20  浏览次数:20784 次

JTable的使用
请问如何用JTable 实现鼠标单击表格并获取表格的值输出在界面文本框里?

------解决方案--------------------
Java code
        table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent event) {
                if (!event.getValueIsAdjusting()) {
                    TableModel model = table.getModel();
                    int row = table.getSelectedRow();
                    int column = table.getSelectedColumn();
                    System.out.println(model.getValueAt(row, column));
                }
            }
        });