Hallo ich hoffe ihr könnt mir bei folgender Frage helfen 
Ich habe 2 Jtables und möchte wenn ich eine Zelle anklicke die komplette Zeile auf beiden Tabellen markieren. Leider hab ich das bisher nicht hinbekommen.
Folgendes Snippet:
// markiert nur die Zeile in der aktuellen Tabelle
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (isSelected) {
setBackground(table.getSelectionBackground());
} else {
setBackground(table.getBackground());
}
return comp;
}
// Idee MouseAdapter aber komme dort nicht weiter
public class Action extends MouseAdapter {
JTable[] tables;
JTable table;
public Action (JTable table, JTable... tables) {
this.tables= tables;
this.table = table;
}
public void mousePressed(MouseEvent e) {
int clickedViewRow = this.table.rowAtPoint(new Point(e.getX(), e.getY()));
int clickedModelRowIndex = this.table.convertRowIndexToModel(clickedViewRowIndex);
for (JTable table : this.tables) {
..... wie kann ich nun die komplette Zeile markieren?
}
}
Danke im Voraus und viele Grüße
Ich habe 2 Jtables und möchte wenn ich eine Zelle anklicke die komplette Zeile auf beiden Tabellen markieren. Leider hab ich das bisher nicht hinbekommen.
Folgendes Snippet:
// markiert nur die Zeile in der aktuellen Tabelle
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (isSelected) {
setBackground(table.getSelectionBackground());
} else {
setBackground(table.getBackground());
}
return comp;
}
// Idee MouseAdapter aber komme dort nicht weiter
public class Action extends MouseAdapter {
JTable[] tables;
JTable table;
public Action (JTable table, JTable... tables) {
this.tables= tables;
this.table = table;
}
public void mousePressed(MouseEvent e) {
int clickedViewRow = this.table.rowAtPoint(new Point(e.getX(), e.getY()));
int clickedModelRowIndex = this.table.convertRowIndexToModel(clickedViewRowIndex);
for (JTable table : this.tables) {
..... wie kann ich nun die komplette Zeile markieren?
}
}
Danke im Voraus und viele Grüße