NullPointer Exception while clicking Jtable
Hi When i clicked the JTable for inserting values,i am getting the null pointer exception in the place of dotted line.But JTable calculations are working fine.Why i am getting the Exception?
This is my code:
private void SaleReturnRow_TableMouseClicked(java.awt.event.Mou seEvent evt) {
NumberFormat formatter = new DecimalFormat("#0.00");
int selrow=SaleReturnRow_Table.getSelectedRow();
int slno=selrow+1;
SaleReturnRow_Table.setValueAt(slno,selrow,0);
//Calculating the totalprice,rowtotal
int selcol=SaleReturnRow_Table.getSelectedColumn();
Object quan=SaleReturnRow_Table.getModel().getValueAt(sel row,3);
Object uprice=SaleReturnRow_Table.getModel().getValueAt(s elrow,4);
quant=Double.parseDouble(quan.toString());----------
unitprice=Double.parseDouble(uprice.toString());
//calculating row_total without dis and tax
row_totalprice=quant*unitprice;
//formatting the result with two digits
String row_tp=formatter.format(row_totalprice);
SaleReturnRow_Table.setValueAt(row_tp,selrow,5);
Object dis=SaleReturnRow_Table.getModel().getValueAt(selr ow,6);
row_discount=Double.parseDouble(dis.toString());
Object rowtax=SaleReturnRow_Table.getModel().getValueAt(s elrow,7);
String str_rowtax=rowtax.toString();
if(str_rowtax=="BED+VAT"){
row_tax=23;
}
else{
System.out.println("I am out of else if block");
}
//row_tax=Double.parseDouble(rowtax.toString());
double rowtotal=Math.round(row_totalprice-(row_totalprice*row_discount/100)+(row_totalprice*row_tax/100));
String str_rowtotal=formatter.format(rowtotal);
SaleReturnRow_Table.setValueAt(str_rowtotal,selrow ,8);
}
Re: NullPointer Exception while clicking Jtable
-- No code tags
-- Still cross posting (but not this topic)
-- Mostly doesn't bother to return to started threads
I'm outta here.
db