Hi...I am using a mouselistner on a JTable so i can click on a selected field/tuple within the column of the JTable and take out its infromation. i can get it to print the whole row on the dos screen by using;
table.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { selectedCol(table); } }); . . . private void selectedCol(JTable table) { int row = table.getRowCount(); int col = table.getColumnCount(); . . . }
but when when tryed to get a an individual field/tuple by using; private void selectedCol(JTable table) { int row = table.getSelectedRow(); int col = table.getSelectedColumn(); if (rows == 1) { value = (String)table.getValueAt(row, col); System.out.println("Value =: "+value); } }
i get a value of -1, which in the says in the API a value of -1 means nothing has been selected.