NullPointerException when trying to copy/paste from/into clipboard - java

I have an specific issue with copy/paste from my Java application. I made IT utility that we use in our IT Department for Evidence of our IT assessments.
When I try to copy from anything (jTextArea, jTextField, jTable cell, etc..) I receive bellow shown NullPointerException.
This issue appears randomly, I can copy In/Out all I want, but then, let say hour after, I want to copy some information out and this appears, after that I cannot copy anything in or out and only thing that helps is restarting the application. After Restart, I can try to copy anything anywhere, even use Java Toolkit.getDefaultToolkit().getSystemClipboard() function with no error, but again, after some time (usually after one or more hours) it appears again. For this time, there is only one active scheduled method that keeps refreshing the main table from SQL. I don't think that my code will help here is this application have more that 65K rows ant this issue appears randomly anywhere.
But my question is - Is there any special way to treat system Clipboard, or are there any common mistakes that could make such behavior? I found nothing that could help me understand my problem.
I'll appreciate any help or leads whatsoever, thank you:)
Error message:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.io.Win32FileSystem.normalize(Unknown Source)
at java.io.Win32FileSystem.getUserPath(Unknown Source)
at java.io.Win32FileSystem.resolve(Unknown Source)
at java.io.File.getAbsolutePath(Unknown Source)
at java.io.File.getAbsoluteFile(Unknown Source)
at java.io.File.toURI(Unknown Source)
at java.awt.datatransfer.SystemFlavorMap$1.run(Unknown Source)
at java.awt.datatransfer.SystemFlavorMap$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.datatransfer.SystemFlavorMap.initSystemFlavorMap(Unknown Source)
at java.awt.datatransfer.SystemFlavorMap.getFlavorToNative(Unknown Source)
at java.awt.datatransfer.SystemFlavorMap.getNativesForFlavor(Unknown Source)
at sun.awt.datatransfer.DataTransferer.getFormatsForFlavors(Unknown Source)
at sun.awt.windows.WDataTransferer.getFormatsForFlavors(Unknown Source)
at sun.awt.datatransfer.DataTransferer.getFormatsForTransferable(Unknown Source)
at sun.awt.windows.WClipboard.setContentsNative(Unknown Source)
at sun.awt.datatransfer.SunClipboard.setContents(Unknown Source)
at GUI.Evidence.EvidenceMain.SaveToClip(EvidenceMain.java:711)
at GUI.Evidence.EvidenceMain.access$800(EvidenceMain.java:65)
at GUI.Evidence.EvidenceMain$4.mouseReleased(EvidenceMain.java:401)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.io.IOException: cannot transfer non-text data as Reader
at sun.awt.datatransfer.DataTransferer.translateTransferable(Unknown Source)
at sun.awt.windows.WDataTransferer.translateTransferable(Unknown Source)
at sun.awt.windows.WClipboard.setContentsNative(Unknown Source)
at sun.awt.datatransfer.SunClipboard.setContents(Unknown Source)
at javax.swing.TransferHandler.exportToClipboard(Unknown Source)
at javax.swing.TransferHandler$TransferAction.actionPerformedImpl(Unknown Source)
at javax.swing.TransferHandler$TransferAction.access$700(Unknown Source)
at javax.swing.TransferHandler$TransferAction$1.run(Unknown Source)
at javax.swing.TransferHandler$TransferAction$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at javax.swing.TransferHandler$TransferAction$2.run(Unknown Source)
at javax.swing.TransferHandler$TransferAction$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at javax.swing.TransferHandler$TransferAction.actionPerformed(Unknown Source)
at javax.swing.text.JTextComponent.invokeAction(Unknown Source)
at javax.swing.text.JTextComponent.copy(Unknown Source)
at javax.swing.text.DefaultEditorKit$CopyAction.actionPerformed(UnknownSource)
at javax.swing.SwingUtilities.notifyAction(Unknown Source)
at javax.swing.JComponent.processKeyBinding(Unknown Source)
at javax.swing.JComponent.processKeyBindings(Unknown Source)
at javax.swing.JComponent.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Related

JTable RowSorter throws IndexOutOfBoundException even if index < size

When I try to sort one column immediately after the Jtable is loaded, I get IndexOutOfBoundException even if index is lesser than the size. I feel that even if the table has finished loading, there are some updates happening on the table model. Is there any way to detect if all the updates on the table model are finished?
I am using Jtable's AutoCreateRowSorter.
Thank you in advance. Below is the stacktrace.
`ERROR: 11:15:37,789 -
Logger$IC_UncaughtExceptionHandler.uncaughtException:?
java.lang.IndexOutOfBoundsException
java.lang.IndexOutOfBoundsException: Index: 530, Size: 1637
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.rac.cif.common.CIFTableModel.getRowLine(Unknown Source)
at com.my.dff.center.unified.table.MyCIFTableModelDFF.getValueAt(MyCIFTableModelDFF.java:51)
at com.rac.cif.common.CIFTableModel.getValueAt(Unknown Source)
at javax.swing.table.TableRowSorter$TableRowSorterModelWrapper.getValueAt(Unknown Source)
at javax.swing.table.TableRowSorter$TableRowSorterModelWrapper.getStringValueAt(Unknown Source)
at javax.swing.DefaultRowSorter.compare(Unknown Source)
at javax.swing.DefaultRowSorter.access$100(Unknown Source)
at javax.swing.DefaultRowSorter$Row.compareTo(Unknown Source)
at javax.swing.DefaultRowSorter$Row.compareTo(Unknown Source)
at java.util.ComparableTimSort.countRunAndMakeAscending(Unknown Source)
at java.util.ComparableTimSort.sort(Unknown Source)
at java.util.ComparableTimSort.sort(Unknown Source)
at java.util.Arrays.sort(Unknown Source)
at javax.swing.DefaultRowSorter.sort(Unknown Source)
at javax.swing.DefaultRowSorter.setSortKeys(Unknown Source)
at javax.swing.DefaultRowSorter.toggleSortOrder(Unknown Source)
at javax.swing.plaf.basic.BasicTableHeaderUI$MouseInputHandler.mouseClicked(Unknown Source)
at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at com.rac.cif.common.CIFTable$1.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)`

java.lang.IllegalArgumentException: null delegate icon argument

I have created Java project in Eclipse. First login page and after login page Main Frame is there which contain JMenubar...after clicking JMenuItem another JInternalFrame open. It works well in Eclipse...but if I tried to open through jar only login page open and not move on another frame...so tried on cmd
java -jar C:\Users\Dell\Desktop\26thJuly.jar so it gives error:-
java.lang.IllegalArgumentException: null delegate icon argument
at javax.swing.plaf.IconUIResource.<init>(Unknown Source)
at javax.swing.plaf.metal.OceanTheme$IFIcon.<init>(Unknown Source)
at javax.swing.plaf.metal.OceanTheme$4.createValue(Unknown Source)
at javax.swing.UIDefaults.getFromHashtable(Unknown Source)
at javax.swing.UIDefaults.get(Unknown Source)
at javax.swing.MultiUIDefaults.get(Unknown Source)
at javax.swing.UIDefaults.getIcon(Unknown Source)
at javax.swing.UIManager.getIcon(Unknown Source)
at javax.swing.plaf.basic.BasicInternalFrameTitlePane.installDefaults(Unknown Source)
at javax.swing.plaf.metal.MetalInternalFrameTitlePane.installDefaults(Unknown Source)
at javax.swing.plaf.basic.BasicInternalFrameTitlePane.installTitlePane(Unknown Source)
at javax.swing.plaf.basic.BasicInternalFrameTitlePane.<init>(Unknown Source)
at javax.swing.plaf.metal.MetalInternalFrameTitlePane.<init>(Unknown Source)
at javax.swing.plaf.metal.MetalInternalFrameUI.createNorthPane(Unknown Source)
at javax.swing.plaf.basic.BasicInternalFrameUI.installComponents(Unknown Source)
at javax.swing.plaf.basic.BasicInternalFrameUI.installUI(Unknown Source)
at javax.swing.plaf.metal.MetalInternalFrameUI.installUI(Unknown Source)
at javax.swing.JComponent.setUI(Unknown Source)
at javax.swing.JInternalFrame.setUI(Unknown Source)
at javax.swing.JInternalFrame.updateUI(Unknown Source)
at javax.swing.JInternalFrame.<init>(Unknown Source)
at javax.swing.JInternalFrame.<init>(Unknown Source)
at stock.<init>(stock.java:114)
at New_Second.<init>(New_Second.java:58)
at Hlogin$2.actionPerformed(Hlogin.java:97)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Use an execution environment JRE JavaSE-1.8

JFileChooser java.lang.IndexOutOfBoundsException: Invalid index

In a Java Swing application, sometimes the error below occurs:
java.lang.IndexOutOfBoundsException: Invalid index
at javax.swing.DefaultRowSorter.convertRowIndexToModel(Unknown Source)
at sun.swing.FilePane$SortableListModel.getElementAt(Unknown Source)
at javax.swing.JList.getSelectedValue(Unknown Source)
It happens when the user browses directories using the JFileChooser. The exception is printed to the output consolle , but it seems that it does not cause any apparent problem. I can't reproduce this error, but it occurs on customers' machines. Can I ignore this exception? Could it cause some other hidden malfunctions?
The complete stack trace is below.
Java version is 1.8.0_45.
java.lang.IndexOutOfBoundsException: Invalid index
at javax.swing.DefaultRowSorter.convertRowIndexToModel(Unknown Source)
at sun.swing.FilePane$SortableListModel.getElementAt(Unknown Source)
at javax.swing.JList.getSelectedValue(Unknown Source)
at javax.swing.plaf.basic.BasicFileChooserUI$Handler.valueChanged(Unknown Source)
at javax.swing.JList.fireSelectionValueChanged(Unknown Source)
at javax.swing.JList$ListSelectionHandler.valueChanged(Unknown Source)
at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
at javax.swing.DefaultListSelectionModel.setValueIsAdjusting(Unknown Source)
at javax.swing.JList.setValueIsAdjusting(Unknown Source)
at javax.swing.plaf.basic.BasicListUI$Handler.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.WaitDispatchSupport$2.run(Unknown Source)
at java.awt.WaitDispatchSupport$4.run(Unknown Source)
at java.awt.WaitDispatchSupport$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(Unknown Source)
at java.awt.Dialog.show(Unknown Source)
at javax.swing.JFileChooser.showDialog(Unknown Source)
at javax.swing.JFileChooser.showOpenDialog(Unknown Source)
Its a bug in Java: http://bugs.java.com/view_bug.do?bug_id=6684952
Ask the customer to use a newer version of java.

java.lang.SecurityException: Resource is not accessible

I'm receiving this exception when accessing the cells of a JTable. It happens specifically when I click off the first cell and move to the second cell. The error started appearing in Java 7 update 45. In update 51, the error no longer appears, but the cells lock up instead. Below is the rather long stack trace.
Since I assumed it had to do with the new security measures being added to java, I've tried to make the application compliant by signing all the jars and adding the appropriate manifest attributes. But the issue still persists. Any ideas would be greatly appreciated.
java.lang.SecurityException: Resource is not accessible
at sun.swing.SwingUtilities2.checkAccess(Unknown Source)
at javax.swing.text.DefaultFormatter.stringToValue(Unknown Source)
at javax.swing.text.DefaultFormatter.updateValue(Unknown Source)
at javax.swing.text.DefaultFormatter.replace(Unknown Source)
at javax.swing.text.DefaultFormatter.replace(Unknown Source)
at javax.swing.text.DefaultFormatter$DefaultDocumentFilter.replace(Unknown Source)
at javax.swing.text.AbstractDocument.replace(Unknown Source)
at javax.swing.text.JTextComponent.setText(Unknown Source)
at javax.swing.DefaultCellEditor$1.setValue(Unknown Source)
at javax.swing.DefaultCellEditor.getTableCellEditorComponent(Unknown Source)
at com.company.common.ui.table.MoneyCellEditor.getTableCellEditorComponent(MoneyCellEditor.java:67)
at javax.swing.JTable.prepareEditor(Unknown Source)
at javax.swing.JTable.editCellAt(Unknown Source)
at javax.swing.plaf.basic.BasicTableUI$Handler.adjustSelection(Unknown Source)
at javax.swing.plaf.basic.BasicTableUI$Handler.mousePressed(Unknown Source)
at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at com.company.app.core.InactivityTrackingSystemEventQueue.dispatchEvent(InactivityTrackingSystemEventQueue.java:120)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.WaitDispatchSupport$2.run(Unknown Source)
at java.awt.WaitDispatchSupport$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(Unknown Source)
at java.awt.Dialog.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at java.awt.Window.setVisible(Unknown Source)
at java.awt.Dialog.setVisible(Unknown Source)
at com.company.app.ui.invoice.UpdateNonInventoryItemCostPanel.showDialog(UpdateNonInventoryItemCostPanel.java:235)
at com.company.app.ui.invoice.NonInventoryItemReconciliation.showItemReconciliationDialog(NonInventoryItemReconciliation.java:74)
at com.company.app.ui.invoice.ApproveInvoicePanel$8.done(ApproveInvoicePanel.java:959)
at com.company.app.util.BackgroundWorker.handleDone(BackgroundWorker.java:79)
at com.company.app.util.BackgroundWorker$SwingWorkerImpl.done(BackgroundWorker.java:118)
at javax.swing.SwingWorker$5.run(Unknown Source)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(Unknown Source)
at sun.swing.AccumulativeRunnable.run(Unknown Source)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(Unknown Source)
at javax.swing.Timer.fireActionPerformed(Unknown Source)
at javax.swing.Timer$DoPostEvent.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at com.company.app.core.InactivityTrackingSystemEventQueue.dispatchEvent(InactivityTrackingSystemEventQueue.java:120)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.WaitDispatchSupport$2.run(Unknown Source)
at java.awt.WaitDispatchSupport$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(Unknown Source)
at java.awt.Dialog.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at java.awt.Window.setVisible(Unknown Source)
at java.awt.Dialog.setVisible(Unknown Source)
at com.company.app.ui.invoice.ApproveInvoicePanel.showDialog(ApproveInvoicePanel.java:755)
at com.company.app.ui.quotes.purchaseorder.PurchaseOrderSupplierInvoicesListPanel$3.done(PurchaseOrderSupplierInvoicesListPanel.java:195)
at com.company.app.util.BackgroundWorker.handleDone(BackgroundWorker.java:79)
at com.company.app.util.BackgroundWorker$SwingWorkerImpl.done(BackgroundWorker.java:118)
at javax.swing.SwingWorker$5.run(Unknown Source)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(Unknown Source)
at sun.swing.AccumulativeRunnable.run(Unknown Source)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(Unknown Source)
at javax.swing.Timer.fireActionPerformed(Unknown Source)
at javax.swing.Timer$DoPostEvent.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at com.company.app.core.InactivityTrackingSystemEventQueue.dispatchEvent(InactivityTrackingSystemEventQueue.java:120)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

NullPointerException in constructor

I have narrowed down my problem to one line of Java code in my GUI.
Shop1.addProduct(new Product(proid, proName, proPrice, proQis));
Each time I click the button that I've attached it to. It isn't the button as that runs fine without it.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at ShopFrame$AddListener.actionPerformed(ShopFrame.java:56)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
I can't for the life of me figure out the problem.
It seems that Shop1 is null. Try adding a null-check:
if(Shop1 != null) Shop1.addProduct(new Product(proid, proName, proPrice, proQis));
Also, as an aside note, follow Java naming conventions and don't start your variables with capital letters. Instead of Shop1, use shop1.

Categories