Hi, I have this strange bug with my popup menu. It happens rarely and seemingly randomly. The problem is when I have a submenu in my JPopupMenu - when I select the submenu, main menu disappears and the submenu is painted incorrectly (it's like the buffer of main menu is painted over the submenu). I can still navigate it using keyboard.
Here are some screenshots: This is how it should look like
And this is what it looks like when the bug appears:
So that glitch on the second picture is where the submenu should've been.
My code for showing the menu
addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
show(e);
}
@Override
public void mouseReleased(MouseEvent e) {
show(e);
}
public void show(MouseEvent e) {
if (e.isPopupTrigger()) {
if (selectSongsAt(e.getPoint())) {
JPopupMenu popup = buildTableMenu();
popup.show(e.getComponent(), e.getX(), e.getY());
}
}
}
});
It's a JTable, selectSongsAt()
just selects rows at given location and buildTableManu()
returns new JPopupMenu.
What could cause this? There are no exceptions thrown, it doesn't seem platform-related, so I have no idea how to narrow this down. Please help.