I was working on a project under windows and it works perfectly, but when I moved it to linux, weird things started to happen. But I won't ask more than one question in this one, Let's start with JPopupmenu not working at all. Under windows : I have a JTable and JPopupmenu which should be visible inside the JTable, I added the JPopupmenu from swing directly. Here is the trigger code :
private void jTable2MouseReleased(java.awt.event.MouseEvent evt) {
if (evt.isPopupTrigger()) {
int rows = jTable2.getRowCount();
if(rows>0){
JTable source = (JTable) evt.getSource();
int row = source.rowAtPoint(evt.getPoint());
int column = source.columnAtPoint(evt.getPoint());
if (!source.isRowSelected(row)) {
source.changeSelection(row, column, false, false);
}
jPopupMenu1.show(evt.getComponent(), evt.getX(), evt.getY());
}
}
}
As the code shows: the Popupmenu should be visible when the rows inside JTable greater than zero. It works under windows but noting happen on Linux. What did I miss here ?
Ok I found it, I have to add the same code in JTableMousePressed event and it will work as it should.