0

I want to do mouse right click PopupMenu in my programme but i am getting some error. Engrossingly, my programme is working,also Popmenu is opening, but why the NetBean IDE is giving that error ? My code is like that:

private void pnlKullaniciSor_jTableMouseReleased(java.awt.event.MouseEvent evt) {                                                     
    try{
    if (evt.isPopupTrigger()){
        jPopupMenu1.show(evt.getComponent(),evt.getX(),evt.getY());
    }
    }catch(Exception exp){
        JOptionPane.showMessageDialog(null, exp);
    }
}                          

But i getting this error :

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
    at java.util.Vector.elementData(Vector.java:734)
    at java.util.Vector.elementAt(Vector.java:477)
    at javax.swing.table.DefaultTableModel.getValueAt(DefaultTableModel.java:648)
    at javax.swing.JTable.getValueAt(JTable.java:2717)
    at stoktakipvol1.Yonetim.pnlKullaniciSor_jTableMousePressed(Yonetim.java:1162)
    at stoktakipvol1.Yonetim.access$1700(Yonetim.java:6)
    at stoktakipvol1.Yonetim$8.mousePressed(Yonetim.java:420)
    at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:280)
    at java.awt.Component.processMouseEvent(Component.java:6530)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6298)
    at java.awt.Container.processEvent(Container.java:2236)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4522)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
    at java.awt.Container.dispatchEventImpl(Container.java:2280)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
    at java.util.Vector.elementData(Vector.java:734)
    at java.util.Vector.elementAt(Vector.java:477)
    at javax.swing.table.DefaultTableModel.getValueAt(DefaultTableModel.java:648)
    at javax.swing.JTable.getValueAt(JTable.java:2717)
    at stoktakipvol1.Yonetim.pnlKullaniciSor_jTableMousePressed(Yonetim.java:1162)
    at stoktakipvol1.Yonetim.access$1700(Yonetim.java:6)
    at stoktakipvol1.Yonetim$8.mousePressed(Yonetim.java:420)
    at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:280)
    at java.awt.Component.processMouseEvent(Component.java:6530)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6298)
    at java.awt.Container.processEvent(Container.java:2236)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4522)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
    at java.awt.Container.dispatchEventImpl(Container.java:2280)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

@Tiago_nes
Vector ,line 734:

E elementData(int index) {
        return (E) elementData[index];
    }

    /**
     * Returns the element at the specified position in this Vector.
     *
     * @param index index of the element to return
     * @return object at the specified index
     * @throws ArrayIndexOutOfBoundsException if the index is out of range
     *            ({@code index < 0 || index >= size()})

    public synchronized E get(int index) {
        if (index >= elementCount)
            throw new ArrayIndexOutOfBoundsException(index);
        return elementData(index);
    }

i used try-catch block but it's still giving the same error. Thanks for your helps... ( May the code be with you )

Babafingo
  • 1
  • 2
  • somewhere you are using an array and try to access position `-1`. it happens somewhere within your table – XtremeBaumer Dec 19 '17 at 11:48
  • @XtremeBaumer My jtable is NetBeans's automatic Generated Code. I didn't use any array. But,generated code has an array like that : new Object [][] { {null, null, null, null, null, null, null}, {null, null, null, null, null, null, null}, {null, null, null, null, null, null, null}, {null, null, null, null, null, null, null} }, new String [] { "Sicil", "Adı", "Soyadı", "Birimi", "Daili Tel", "Cep Tel", "E-Posta" } – Babafingo Dec 19 '17 at 12:06
  • @Tiago_nes that is irrelevant. its default java source code. nothing in there would be interesting to know. its about the code OP wrote. did you debug your code? if not, start at `at stoktakipvol1.Yonetim$8.mousePressed(Yonetim.java:420)` – XtremeBaumer Dec 19 '17 at 12:08
  • And even when this would **not** be a basic thing that you should learn about first - we would need a true [mcve] in order to be able to help you. And hint: dont put information into comments. Edit/improve your question instead. And then: spend some time at the [help] to learn how/what to ask here. – GhostCat Dec 19 '17 at 12:14
  • @XtremeBaumer yeah,now i did. And the result output: "Listening on javadebug,User program running, User program finished." As u see, there is no error in the Debugger Console – Babafingo Dec 19 '17 at 12:17
  • @GhostCat yes sir u totaly right. There is minumum information and example in right here. But i think error output is enough to understand why it arises. And also tx, i gonna check out the help center. – Babafingo Dec 19 '17 at 12:26
  • @XtremeBaumer Yea sorry haven't realized that. Can you post the full code? – Tiago_nes Dec 19 '17 at 12:28
  • @Tiago_nes which full code u need ? Full Project ? – Babafingo Dec 19 '17 at 13:29
  • At least full class get a link to it. – Tiago_nes Dec 19 '17 at 13:30
  • Holy jesus,i found the reason and solved my problem. Tx for everbody guys.. So, should i answer the post why it gives this error ? – Babafingo Dec 20 '17 at 11:09

0 Answers0