fix popup doesn't appear when left click
added cell selection when displaying popup
This commit is contained in:
parent
336288b71a
commit
28d2b300f1
1 changed files with 17 additions and 3 deletions
|
@ -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());
|
||||
}
|
||||
|
|
Reference in a new issue