• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help! MouseListener/JTable Question

 
Peter Nelson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
below is an example of code I'm trying to use in my final project -
When I try to compile it I get an
<identifier> expected resultTable.addMouseListener(new MouseAdapter() {
error (there is a carrot right under the ( before new
I'm sure its me being stupid - please Help? The basic Idea of what I want to acomplish is to have the uer select a row, and then pipe the retrieved data to a textfield.
thanks in advance to anyone that responds
resultTable.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
// get most recently selected row index
int row = getSelectedRow();
// get most recently selected column index
int column = getSelectedColumn();
if (row == -1 || column == -1)
return; // can't determine selected cell
else {
String stuff =(String) resultTable.getValueat( row, 0);
typeField.setText(stuff);
}

}
});
 
clio katz
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"getValueat" => "getValueAt" ?
 
Peter Nelson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry about that - that was me misstyping - the code is getValueAt
 
clio katz
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can't really tell much more without the full code - only other thing at first glance is that getSelectedXxx methods do not specifically refer to resultTable (eg resultTable.getSelectedXxx..), but addMouseListener and getValueAt do ...
 
Peter Nelson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your help! I figured out what was wrong - it was in the wrong portion of my code.

thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!