Results 1 to 2 of 2
  1. #1
    Subhasri is offline Member
    Join Date
    Sep 2011
    Posts
    15
    Rep Power
    0

    Default 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);
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,196
    Rep Power
    19

    Default 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

Similar Threads

  1. Nullpointer Exception with BufferedWriter?
    By Solarsonic in forum New To Java
    Replies: 3
    Last Post: 03-23-2011, 12:08 AM
  2. Nullpointer Exception???
    By kipcorn91 in forum AWT / Swing
    Replies: 5
    Last Post: 10-28-2010, 11:19 PM
  3. NullPointer exception
    By bdario1 in forum New To Java
    Replies: 15
    Last Post: 03-17-2010, 04:44 AM
  4. nullpointer exception in jsp
    By fiero in forum JavaServer Pages (JSP) and JSTL
    Replies: 6
    Last Post: 11-07-2008, 01:44 PM
  5. NullPointer Exception
    By Preethi in forum New To Java
    Replies: 8
    Last Post: 02-06-2008, 03:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •