diff --git a/src/main/java/GUI/Agenda/Agenda.java b/src/main/java/GUI/Agenda/Agenda.java index 47b80ec..1c5b770 100644 --- a/src/main/java/GUI/Agenda/Agenda.java +++ b/src/main/java/GUI/Agenda/Agenda.java @@ -1,6 +1,7 @@ package GUI.Agenda; -import DB.*; +import DB.Competition; +import DB.Projection; import GUI.ProjectionHandler; import GUI.Types.CompetType; import GUI.Types.ProjectionType; @@ -92,6 +93,20 @@ public class Agenda extends JPanel { table.setRowHeight(100); Agenda tmp = this; table.addMouseListener(new MouseInputAdapter() { + @Override + public void mouseReleased(MouseEvent mouseEvent) { + if (mouseEvent.isPopupTrigger()) { + int row = table.rowAtPoint(mouseEvent.getPoint()); + int column = table.getTableHeader().columnAtPoint(mouseEvent.getPoint()); + table.changeSelection(row, column, false, false); + Object currentCellValue = table.getValueAt(row, column); + Projection projection = null; + if (currentCellValue.getClass() == Projection.class) + projection = (Projection) currentCellValue; + PopUpProjection popUpProjection = new PopUpProjection(projection, tmp); + popUpProjection.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY()); + } + } @Override public void mousePressed(MouseEvent mouseEvent) { @@ -105,8 +120,7 @@ public class Agenda extends JPanel { } else { openDialog(ProjectionType.EDIT, projection); } - } - else if (mouseEvent.isPopupTrigger()) { + } else if (mouseEvent.isPopupTrigger()) { PopUpProjection popUpProjection = new PopUpProjection(projection, tmp); popUpProjection.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY()); }