Forums Register Login

Help! MouseListener/JTable Question

+Pie Number of slices to send: Send
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);
}

}
});
+Pie Number of slices to send: Send
"getValueat" => "getValueAt" ?
+Pie Number of slices to send: Send
sorry about that - that was me misstyping - the code is getValueAt
+Pie Number of slices to send: Send
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 ...
+Pie Number of slices to send: Send
Thank you for your help! I figured out what was wrong - it was in the wrong portion of my code.

thanks!
The happiness of your life depends upon the quality of your thoughts -Marcus Aurelius ... think about this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1100 times.
Similar Threads
2 dimensional array without hard coding values
jtable
method takes longer each time
Help needed on editing a specific row in JTable
JTable Columns
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 09:50:54.