Results 1 to 9 of 9
  1. #1
    KarlNorway is offline Member
    Join Date
    Dec 2011
    Posts
    57
    Rep Power
    0

    Default Adding to table crashes the program

    Hi Im struggeling with getteing strings to go into a table.
    Here is the code that makes it fail:
    Java Code:
    public void printData(){
    Iterator it = myItems.iterator();
                while(it.hasNext()) {
                    Item = it.next().toString();
                    System.out.println(Item);  // gives this output: 319097,PCB SIO_1,0,1
     
     // splitting it into a array of four items
    String delimiter = ",";
                      
                      XMLItem = Item.split(delimiter);
                       for(int i =0; i < XMLItem.length ; i++)
                        System.out.println(XMLItem[i]);
                      System.out.println(XMLItem.length);
    //                TableItem items = new TableItem(table, SWT.NONE); // when these tow lines are uncommented I get error. I have tried with this line above the while loop
    //                  items.setText(XMLItem);  
                }
    Here is the error output
    Java Code:
    java.lang.IllegalArgumentException: Argument cannot be null
        at org.eclipse.swt.SWT.error(SWT.java:4263)
        at org.eclipse.swt.SWT.error(SWT.java:4197)
        at org.eclipse.swt.SWT.error(SWT.java:4168)
        at org.eclipse.swt.widgets.TableItem.checkNull(TableItem.java:123)
        at org.eclipse.swt.widgets.TableItem.<init>(TableItem.java:77)
        at view.Main.printData(Main.java:354)
        at view.Main.parseXML(Main.java:238)
        at view.Main.openXML(Main.java:224)
        at view.Main$2.widgetSelected(Main.java:117)
        at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
        at view.Main.open(Main.java:81)
        at view.Main.main(Main.java:65)
    From the ine numbers in the error report I have found it to be the when I try to add to or open table

    I have one other routing that puts strings from txt input into the table and it works great..

    Anyone that can help a n00b out?
    Last edited by KarlNorway; 01-28-2012 at 03:26 PM.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,894
    Rep Power
    25

    Default Re: Adding to table crashes the program

    IllegalArgumentException: Argument cannot be null
    What variable has a null value? What doesn't it have a non-null value?
    Find the variable that is null and backtrack to find out why it does not have a value.

    Your code does not show where table is given a value.

  3. #3
    KarlNorway is offline Member
    Join Date
    Dec 2011
    Posts
    57
    Rep Power
    0

    Default Re: Adding to table crashes the program

    Do you mean the code that sets up the entire table?

    I think I know what happens. The button used to fill in ( open XML) is stated before the table and the buton to add into the table is stated after the table. I dont have the code in front of me rigth now.

    Could this be the issue you think?

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,894
    Rep Power
    25

    Default Re: Adding to table crashes the program

    Is it the variable: table that is null?
    You have to look at the code and see why the table variable is null?

    Add some printlns to show you the execution flow and when table is given a value.

  5. #5
    KarlNorway is offline Member
    Join Date
    Dec 2011
    Posts
    57
    Rep Power
    0

    Default Re: Adding to table crashes the program

    Ok ill look at it when i have the cin front of me

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Adding to table crashes the program

    Moved from 'New to Java'

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    KarlNorway is offline Member
    Join Date
    Dec 2011
    Posts
    57
    Rep Power
    0

    Default Re: Adding to table crashes the program

    Im kinda lost here.

    Here is one system.out.println of parsed item before and after split:
    Java Code:
    320077,TD30V cNODE Maxi34-St,250,3
    320077
    TD30V cNODE Maxi34-St
    250
    3

    even doing it like this
    Java Code:
    String [] one = {"1","1","1","1"};
    TableItem items = new TableItem(table, SWT.NONE);
    			items.setText(one);
    crashes the program with same error. when I do it inside the print data void. If I just put the above code inside the button function I get expected result. a 1 in every column

    It could seem to me that the string array passed to the table is missing.
    If I use the system out print of the splittet strings (and dont use [i] behind) I get something like this
    Java Code:
    [Ljava.lang.String;@82c01f
    And I dont know what this means
    Last edited by KarlNorway; 01-30-2012 at 08:14 AM.

  8. #8
    KarlNorway is offline Member
    Join Date
    Dec 2011
    Posts
    57
    Rep Power
    0

    Default Re: Adding to table crashes the program

    Looks like I present the data wrong to the table.

    Maybe I should add a listener to the table?
    Last edited by KarlNorway; 01-30-2012 at 08:53 AM.

  9. #9
    KarlNorway is offline Member
    Join Date
    Dec 2011
    Posts
    57
    Rep Power
    0

    Default Re: Adding to table crashes the program

    Solved it..

    Error was in where I start the parser..

    Java Code:
    Main dpe = new Main();
    dpe.parseXML();
    Is taken from the example I have used to look at. Did nothing but destroy my application. Commented out and did just
    Java Code:
     parseXML();
    everything worked.

Similar Threads

  1. LeapYear program crashes.
    By BangingWang in forum New To Java
    Replies: 14
    Last Post: 08-26-2011, 02:04 PM
  2. adding sum column on jtable that is binded to a database table
    By madcloud in forum Enterprise JavaBeans (EJB)
    Replies: 4
    Last Post: 12-06-2010, 09:26 AM
  3. Program crashes: NullPointerException
    By d4nce2thisbeat in forum New To Java
    Replies: 5
    Last Post: 11-20-2010, 10:33 PM
  4. After adding new columns to my Table
    By joker.med in forum New To Java
    Replies: 5
    Last Post: 04-30-2010, 08:33 PM
  5. Adding a progress bar to a table
    By djc in forum NetBeans
    Replies: 3
    Last Post: 07-11-2008, 01:31 AM

Posting Permissions

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