Results 1 to 9 of 9
- 01-28-2012, 11:59 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 57
- Rep Power
- 0
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:
Here is the error outputJava 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); }
From the ine numbers in the error report I have found it to be the when I try to add to or open tableJava 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)
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 02:26 PM.
- 01-28-2012, 01:07 PM #2
Re: Adding to table crashes the program
What variable has a null value? What doesn't it have a non-null value?IllegalArgumentException: Argument cannot be null
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.
- 01-28-2012, 02:25 PM #3
Member
- Join Date
- Dec 2011
- Posts
- 57
- Rep Power
- 0
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?
- 01-28-2012, 02:27 PM #4
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.
- 01-28-2012, 02:38 PM #5
Member
- Join Date
- Dec 2011
- Posts
- 57
- Rep Power
- 0
Re: Adding to table crashes the program
Ok ill look at it when i have the cin front of me
- 01-28-2012, 04:17 PM #6
Re: Adding to table crashes the program
Moved from 'New to Java'
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 01-30-2012, 07:03 AM #7
Member
- Join Date
- Dec 2011
- Posts
- 57
- Rep Power
- 0
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 thiscrashes 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 columnJava Code:String [] one = {"1","1","1","1"}; TableItem items = new TableItem(table, SWT.NONE); items.setText(one);
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
And I dont know what this meansJava Code:[Ljava.lang.String;@82c01f
Last edited by KarlNorway; 01-30-2012 at 07:14 AM.
- 01-30-2012, 07:40 AM #8
Member
- Join Date
- Dec 2011
- Posts
- 57
- Rep Power
- 0
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 07:53 AM.
- 01-30-2012, 11:03 AM #9
Member
- Join Date
- Dec 2011
- Posts
- 57
- Rep Power
- 0
Re: Adding to table crashes the program
Solved it..
Error was in where I start the parser..
Is taken from the example I have used to look at. Did nothing but destroy my application. Commented out and did justJava Code:Main dpe = new Main(); dpe.parseXML();
everything worked.Java Code:parseXML();
Similar Threads
-
LeapYear program crashes.
By BangingWang in forum New To JavaReplies: 14Last Post: 08-26-2011, 01:04 PM -
adding sum column on jtable that is binded to a database table
By madcloud in forum Enterprise JavaBeans (EJB)Replies: 4Last Post: 12-06-2010, 08:26 AM -
Program crashes: NullPointerException
By d4nce2thisbeat in forum New To JavaReplies: 5Last Post: 11-20-2010, 09:33 PM -
After adding new columns to my Table
By joker.med in forum New To JavaReplies: 5Last Post: 04-30-2010, 07:33 PM -
Adding a progress bar to a table
By djc in forum NetBeansReplies: 3Last Post: 07-11-2008, 12:31 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks