Results 1 to 8 of 8
Thread: trying to calculate jTable row
 11232016, 10:09 AM #1Member
 Join Date
 Nov 2016
 Posts
 31
 Rep Power
 0
trying to calculate jTable row
My code: I get error: Exception in thread "AWTEventQueue0" java.lang.NumberFormatException: For input string: "10,10"
Java Code:public BlagajnaVnos() { initComponents(); retreve(); jTextField4.setText(Integer.toString(getSum())); } public int getSum(){ int rowsCount = jTable1.getRowCount(); int sum = 0; for(int i = 0; i < rowsCount; i++){ sum = sum+Integer.parseInt(jTable1.getValueAt(i, 3).toString()); } return sum; }
 11232016, 10:25 AM #2Moderator
 Join Date
 Apr 2009
 Posts
 13,541
 Rep Power
 26
Re: trying to calculate jTable row
That value is not a valid integer.
When posting exceptions you should also tell us what line in your code it is thrown from.Please do not ask for code as refusal often offends.
** This space for rent **
 11232016, 01:18 PM #3Member
 Join Date
 Nov 2016
 Posts
 31
 Rep Power
 0
 11232016, 01:52 PM #4Moderator
 Join Date
 Apr 2009
 Posts
 13,541
 Rep Power
 26
Re: trying to calculate jTable row
Well, assuming you want to keep the decimal value then you ought to be using a Double.
Please do not ask for code as refusal often offends.
** This space for rent **
 11232016, 03:08 PM #5Member
 Join Date
 Nov 2016
 Posts
 31
 Rep Power
 0
Re: trying to calculate jTable row
Can you show me how to use Double in my code?
 11232016, 03:39 PM #6
Re: trying to calculate jTable row
Java Code:double value = Double.parseDouble( yourString )
Java Code:NumberFormat dutch = NumberFormat.getInstance( new Locale("nl")); double value = dutch.parse( yourString ).doubleValue();
"It's not fixed until you stop calling the problem weird and you understand what was wrong."  gimbal2™ © 2013
 11232016, 03:57 PM #7Member
 Join Date
 Nov 2016
 Posts
 31
 Rep Power
 0
Re: trying to calculate jTable row
Sorry but I do not following you. Can you please show me how in my code?
Java Code:public BlagajnaVnos() { initComponents(); retreve(); jTextField4.setText(Integer.toString(getSum())); } public int getSum(){ int rowsCount = jTable1.getRowCount(); int sum = 0; for(int i = 0; i < rowsCount; i++){ sum = sum+Integer.parseInt(jTable1.getValueAt(i, 3).toString()); } return sum; }
 11232016, 04:06 PM #8Moderator
 Join Date
 Apr 2009
 Posts
 13,541
 Rep Power
 26
Similar Threads

Calculate PI
By Nasima Ferdous Tripti in forum New To JavaReplies: 4Last Post: 06192014, 08:37 PM 
JTable validate already existing JTable data and set Background colour issue
By pi4r0n in forum AWT / SwingReplies: 4Last Post: 04022012, 08:57 PM 
calculate fft
By ram.west in forum Advanced JavaReplies: 2Last Post: 08272008, 04:05 AM 
Jtable duplicates through Hashtable (JTable condition problem) my assignment plz help
By salmanpirzada1 in forum Advanced JavaReplies: 2Last Post: 05152008, 11:15 AM 
Calculate what e1 and e2 should be
By Legoland in forum New To JavaReplies: 11Last Post: 07022007, 07:01 PM
Bookmarks