hei, please help me.
I have a project sales ..
in the form of sales transactions I would add an update on caret functions texfield subtotal. caretupdate function I use to buy goods at more than one then it will be totaled automatically which will go on with new texfield I gave the name Total.

caretupdate the following code:

private void SubTotalCaretUpdate (javax.swing.event.CaretEvent EVT) {
/ / TODO add your handling code here:
double d, e;
d = Double.parseDouble (SubTotal.getText ());
e = Double.parseDouble (Total.getText ());
e = e + d;
Total.setText (String.valueOf (e));
}

when I make the code above. it appears the error:

Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: empty String
        at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:994)
        at java.lang.Double.parseDouble(Double.java:510)
        at aplikasipenjualan.FrmBrgMasuk.SubTotalCaretUpdate(FrmBrgMasuk.java:486)
        at aplikasipenjualan.FrmBrgMasuk.access$400(FrmBrgMasuk.java:28)
        at aplikasipenjualan.FrmBrgMasuk$5.caretUpdate(FrmBrgMasuk.java:199)
        at javax.swing.text.JTextComponent.fireCaretUpdate(JTextComponent.java:391)
        at javax.swing.text.JTextComponent$MutableCaretEvent.fire(JTextComponent.java:4389)
        at javax.swing.text.JTextComponent$MutableCaretEvent.stateChanged(JTextComponent.java:4411)
        at javax.swing.text.DefaultCaret.fireStateChanged(DefaultCaret.java:782)
        at javax.swing.text.DefaultCaret.changeCaretPosition(DefaultCaret.java:1257)
        at javax.swing.text.DefaultCaret.handleSetDot(DefaultCaret.java:1153)
        at javax.swing.text.DefaultCaret.setDot(DefaultCaret.java:1134)
        at javax.swing.text.DefaultCaret$Handler.removeUpdate(DefaultCaret.java:1777)
        at javax.swing.text.AbstractDocument.fireRemoveUpdate(AbstractDocument.java:243)
        at javax.swing.text.AbstractDocument.handleRemove(AbstractDocument.java:608)
        at javax.swing.text.AbstractDocument.remove(AbstractDocument.java:576)
        at javax.swing.text.AbstractDocument.replace(AbstractDocument.java:652)
        at javax.swing.text.JTextComponent.setText(JTextComponent.java:1693)
        at aplikasipenjualan.FrmBrgMasuk.BersihData(FrmBrgMasuk.java:711)
        at aplikasipenjualan.FrmBrgMasuk.AddNewActionPerformed(FrmBrgMasuk.java:469)
        at aplikasipenjualan.FrmBrgMasuk.access$700(FrmBrgMasuk.java:28)
        at aplikasipenjualan.FrmBrgMasuk$8.actionPerformed(FrmBrgMasuk.java:231)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
        at java.awt.Component.processMouseEvent(Component.java:6263)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
        at java.awt.Component.processEvent(Component.java:6028)
        at java.awt.Container.processEvent(Container.java:2041)
        at java.awt.Component.dispatchEventImpl(Component.java:4630)
        at java.awt.Container.dispatchEventImpl(Container.java:2099)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
        at java.awt.Container.dispatchEventImpl(Container.java:2085)
        at java.awt.Window.dispatchEventImpl(Window.java:2475)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

please help me for fix this code...

well, what do you think this will do

d = Double.parseDouble (SubTotal.getText ());

if SubTotal's value is ""? before you do something as above:

d = 0;
if ( !SubTotal.getText().equals(""))
d = Double.parseDouble(SubTotal.getText());

owh,, still can not also admin .. um,,
I send my project admin can help justify the error code.
the project's results can be entered into the database correctly. formnya always just result in an error.

http://www.4shared.com/rar/zn4q8hnr/AplikasiPenjualan.html

the link above is the link to download porject sales I made.

please help me to fix code.

I just showed you how that error can be avoided. but throwing and catching exceptions can help as well. exception handling is very important for every decent application.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.