java - How can I show a JTable in a dialog box in NetBeans? -


i have had few problems trying table show in netbeans. here code trying use. aware loop wrong , fix @ later date. runtime error following code , can't work out.

object[][] data = null; string[] columnnames = {"type", "grade", "height", "width", "length", "reinforced bottom", "reinforced corners", "sealable", "quantity"};  jtable table = new jtable();  public void showtotalorder(){     for(int i=0; i<boxes.size(); i++){         for(int j=0; j<1; j++){             data[i][j] = boxes.get(i).getname();             data[i][j+1] = boxes.get(i).getgrade();             data[i][j+2] = boxes.get(i).getheight();             data[i][j+3] = boxes.get(i).getwidth();             data[i][j+4] = boxes.get(i).getlength();             data[i][j+5] = boxes.get(i).getreinforcedbottom();             data[i][j+6] = boxes.get(i).getreinforcedcorners();             data[i][j+7] = boxes.get(i).getsealable();             data[i][j+8] = boxes.get(i).getquantity();          }     }      joptionpane.showmessagedialog(this, table); } 

i believe problem last line of method.

the error receive is:

exception in thread "awt-eventqueue-0" java.lang.nullpointerexception   @ coursework.flexbox.showtotalorder(flexbox.java:116)   @ coursework.flexbox.currentorderbuttonactionperformed(flexbox.java:530)   @ coursework.flexbox.access$300(flexbox.java:18)   @ coursework.flexbox$4.actionperformed(flexbox.java:435)   @ javax.swing.abstractbutton.fireactionperformed(abstractbutton.java:2018)   @ javax.swing.abstractbutton$handler.actionperformed(abstractbutton.java:2341)   @ javax.swing.defaultbuttonmodel.fireactionperformed(defaultbuttonmodel.java:402)   @ javax.swing.defaultbuttonmodel.setpressed(defaultbuttonmodel.java:259)   @ javax.swing.plaf.basic.basicbuttonlistener.mousereleased(basicbuttonlistener.java:252)   @ java.awt.component.processmouseevent(component.java:6516)   @ javax.swing.jcomponent.processmouseevent(jcomponent.java:3320)   @ java.awt.component.processevent(component.java:6281)   @ java.awt.container.processevent(container.java:2229)   @ java.awt.component.dispatcheventimpl(component.java:4872)   @ java.awt.container.dispatcheventimpl(container.java:2287)   @ java.awt.component.dispatchevent(component.java:4698)   @ java.awt.lightweightdispatcher.retargetmouseevent(container.java:4832)   @ java.awt.lightweightdispatcher.processmouseevent(container.java:4492)   @ java.awt.lightweightdispatcher.dispatchevent(container.java:4422)   @ java.awt.container.dispatcheventimpl(container.java:2273)   @ java.awt.window.dispatcheventimpl(window.java:2719)   @ java.awt.component.dispatchevent(component.java:4698)   @ java.awt.eventqueue.dispatcheventimpl(eventqueue.java:735)   @ java.awt.eventqueue.access$200(eventqueue.java:103)   @ java.awt.eventqueue$3.run(eventqueue.java:694)   @ java.awt.eventqueue$3.run(eventqueue.java:692)   @ java.security.accesscontroller.doprivileged(native method)   @ java.security.protectiondomain$1.dointersectionprivilege(protectiondomain.java:76)   @ java.security.protectiondomain$1.dointersectionprivilege(protectiondomain.java:87)   @ java.awt.eventqueue$4.run(eventqueue.java:708)   @ java.awt.eventqueue$4.run(eventqueue.java:706)   @ java.security.accesscontroller.doprivileged(native method)   @ java.security.protectiondomain$1.dointersectionprivilege(protectiondomain.java:76)   @ java.awt.eventqueue.dispatchevent(eventqueue.java:705)   @ java.awt.eventdispatchthread.pumponeeventforfilters(eventdispatchthread.java:242)   @ java.awt.eventdispatchthread.pumpeventsforfilter(eventdispatchthread.java:161)   @ java.awt.eventdispatchthread.pumpeventsforhierarchy(eventdispatchthread.java:150)   @ java.awt.eventdispatchthread.pumpevents(eventdispatchthread.java:146)   @ java.awt.eventdispatchthread.pumpevents(eventdispatchthread.java:138)   @ java.awt.eventdispatchthread.run(eventdispatchthread.java:91) 

i runtime error following code , can't work out.

given stack trace:

exception in thread "awt-eventqueue-0" java.lang.nullpointerexception     @ coursework.flexbox.showtotalorder(flexbox.java:116)     ... 

you nullpointerexception because of data array initialized null:

object[][] data = null; 

please have read to:


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -