Reputation: 29
How can I perform a mouse event handling when clicking a cell on my DefaultTableModel
for example when clicking the first column of a row it prints the whole row.
static DefaultTableModel dTableModel = new DefaultTableModel(databaseInfo, columns){
public Class getColumnClass(int column) {
Class returnValue;
// Verifying that the column exists (index > 0 && index < number of columns
if ((column >= 0) && (column < getColumnCount())) {
returnValue = getValueAt(0, column).getClass();
} else {
// Returns the class for the item in the column
returnValue = Object.class;
}
return returnValue;
}
};
thank you .
Upvotes: 0
Views: 753
Reputation: 324118
how can i perfom a mouse event handling when clicking a cell on my DefaultTableModel
The DefaultTableModel has nothing to do with mouse clicks. A TableModel contains the data that is displayed by the table.
for example when clicking the first column of a row it prints the whole row.
Maybe you want to display a "button" the indicates to the user what will happen when you activate the button, either by a mouse click or by using the keyboard?
If so then check out Table Button Column for one solution.
Upvotes: 2