Open eoinzys opened 10 years ago
@eoinzys The stacktrace which you posted gives an error about the card brand. Be sure to fill in all fields so that you only get the error about the card value. Please post an updated stacktrace when you do this.
ah yes sorry about that. heres the stacktrace
INFO: Invalid input bbct.common.exceptions.InputException: Please enter a valid dollar amount. at bbct.swing.gui.CardDetailsPanel.verifyTextField(CardDetailsPanel.java:398) at bbct.swing.gui.CardDetailsPanel.getBaseballCard(CardDetailsPanel.java:144) at bbct.swing.gui.AddCardsPanel$1.actionPerformed(AddCardsPanel.java:79) 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) Caused by: java.text.ParseException: Format.parseObject(String) failed at java.text.Format.parseObject(Unknown Source) at javax.swing.text.NumberFormatter.stringToValue(Unknown Source) at javax.swing.text.InternationalFormatter.stringToValue(Unknown Source) at javax.swing.JFormattedTextField.commitEdit(Unknown Source) at bbct.swing.gui.CardDetailsPanel.verifyTextField(CardDetailsPanel.java:396) ... 38 more
i edited this line and it seems to have fixed the bug line 281 in CardDetailsPanel.java class
this.valueTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(java.text.NumberFormat.getCurrencyInstance())));
changed it to this
this.valueTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(java.text.NumberFormat.getNumberInstance())));
Does this allow the user to type a $ or any other currency symbol?
it doesn't allow for a symbol to be added. wasnt sure if the $, £ symbol was required
i think potentially having a drop down box with a few of the currencies alongside the current text field might be the best option? have dollar as default. else a user may or may not enter a symbol with the value.
@eoinzys Shouldn't you be able to detect user's currency using NumberFormat.getCurrencyInstance().getCurrency().getSymbol()
and then display it next to the text field instead of the drop down box?
@tmatek What if the user wants to use a different currency than the one configured with the computer's locale? I think rather than displaying the symbol next to the EditText
, the app should check if the user has typed a currency symbol, and if not concatenate the default one with the numerical value already entered. This leads to the question: should the default currency be USD or should it be based on the computer's locale?
And now I have another question: should the currency be displayed as a symbol or as an abbreviation?
@codeguru42 Currency could be displayed as just a symbol. As for the logic, it would be ok to concatenate the currency based on locale if user hasn't entered anything since the user is more familiar with local currencies.
In the swing application in "add cards" option when attempting to enter "card value" into the relevant text field, and while all other text fields contain data, An invalid input warning appears and an exception is created. this occurs in the cardDetailsPanel.java class. and seems to occur regardless of the vale entered into the text field. for example i entered "2" , "2.00" and "$200" with the same result. Part of the stack trace is show below