سؤال

I'm using Netbeans and I've designed a window with JTable and added MouseEvent listener on JTable component and added this code:

private void productsTableMousePressed(java.awt.event.MouseEvent evt) {
    if(evt.isPopupTrigger()) {
        tablePopupMenu.setLocation(evt.getXOnScreen(), evt.getYOnScreen());
        tablePopupMenu.setVisible(true);
        System.out.println("Fired!");
    }
}

private void productsTableMouseReleased(java.awt.event.MouseEvent evt) {
    if(evt.isPopupTrigger()) {
        tablePopupMenu.setLocation(evt.getXOnScreen(), evt.getYOnScreen());
        tablePopupMenu.setVisible(true);
    }
}

But it works only when I click on some cells. I want to get it working on whole JTable area. How?

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top