I have noticed a strange problem with my program that I just can not figure out. I have included the method that has been flagged up, and the Error that was given. What's confusing me is that I have duplicated this method about 40 times on other buttons, changing only the 'engtf4' to another source where needed. They work perfectly with no errors, yet are written exactly the same. Adding further confusion, the method is executed exactly as intended(even though the error message below is given)?
I have looked around the net for similar problems using keywords - java.lang.NumberFormatException:
For input string: "", I did however notice that all the example sites I saw had reference to a particular value in qoute marks. For example, -java.lang.NumberFormatException
: For input string: "2345". I would appreciate any help I could get, thanks.
METHOD SOURCE CODE:
if (a.getSource() == engBuy4){
getItems();
q = engtf4.getText();
qq = Long.parseLong(q); //////////// LINE 13086
if (qq > 1000000 || total > 1000000){
Error.setText("You can ship a maximum of 1 million items.");
engtf4.setText("");
}
if (qq <= 1000000 && total <= 1000000){
if (qq > rem){
Error.setText("You can ship " + rem + " more items");
engtf4.setText("");
}
if (qq <= rem){
buyShrEng();
engtf4.setText("");
}
}
ERROR MESSAGE:
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Long.parseLong(Unknown Source)
at java.lang.Long.parseLong(Unknown Source)
at DopeWars.DopeWars.mouseReleased(DopeWars.java:13086)
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)