2)I am trying to incorporate a boolean value in my table even though it is not sourced from the database like the rest of the data. All i am trying to do is add a new element to the vector holding the data.
definitionData = new Vector(); definitionData.add(new Boolean(true));
//loop through vector of report definition objects ReportDefinitionPOJO pojo = new ReportDefinitionPOJO(); for(Enumeration e = reports.elements();e.hasMoreElements() { pojo = (ReportDefinitionPOJO)e.nextElement(); //holds data in an individual row
definitionData.add(0, new Boolean(false)); definitionData.add(pojo.getName()); definitionData.add(pojo.getRequester()); definitionData.add(pojo.getDestination()); } //refrsh the vector with the data System.out.println(definitionData); System.out.println(definitionColumns); //dtm.setDataVector(definitionData, definitionColumns); tblReportDefinitions = new JTable(definitionData, definitionColumns);
public void actionPerformed(ActionEvent evt){ delete(); } }
}
Error: [java] java.lang.ClassCastException [java] at javax.swing.table.DefaultTableModel.justifyRows(DefaultTableM odel.java:238) [java] at javax.swing.table.DefaultTableModel.setDataVector(DefaultTabl eModel.java:194) [java] at javax.swing.table.DefaultTableModel.<init>(DefaultTableModel. java:131) [java] at javax.swing.JTable.<init>(JTable.java:403) [java] at com.rgs.client.Definition.<init>(Definition.java:55) [java] at com.rgs.client.ReportDefinitionGUI.delete(ReportDefinitionGUI .java:118) [java] at com.rgs.client.ReportDefinitionGUI.access$300(ReportDefinitio nGUI.java:13) [java] at com.rgs.client.ReportDefinitionGUI$DeleteAction.actionPerform ed(ReportDefinitionGUI.java:188) [java] at javax.swing.AbstractButton.fireActionPerformed(AbstractButton .java:1786) [java] at javax.swing.AbstractButton$ForwardActionEvents.actionPerforme d(AbstractButton.java:1839) [java] at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultBut tonModel.java:420) [java] at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel. java:258) [java] at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Basi cButtonListener.java:245) [java] at java.awt.Component.processMouseEvent(Component.java:5100) [java] at java.awt.Component.processEvent(Component.java:4897) [java] at java.awt.Container.processEvent(Container.java:1569) [java] at java.awt.Component.dispatchEventImpl(Component.java:3615) [java] at java.awt.Container.dispatchEventImpl(Container.java:1627) [java] at java.awt.Component.dispatchEvent(Component.java:3477) [java] at java.awt.LightweightDispatcher.retargetMouseEvent(Container.j ava:3483) [java] at java.awt.LightweightDispatcher.processMouseEvent(Container.ja va:3198) [java] at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3 128) [java] at java.awt.Container.dispatchEventImpl(Container.java:1613) [java] at java.awt.Window.dispatchEventImpl(Window.java:1606) [java] at java.awt.Component.dispatchEvent(Component.java:3477) [java] at java.awt.EventQueue.dispatchEvent(EventQueue.java:456) [java] at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDi spatchThread.java:201) [java] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDisp atchThread.java:151) [java] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.j ava:145) [java] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.j ava:137) [java] at java.awt.EventDispatchThread.run(EventDispatchThread.java:100 )
jefff willis
Ranch Hand
Joined: Sep 29, 2004
Posts: 113
posted
0
This is just a quick evaluation of your code, but I believe I see yout create fours columns of data headers and you try to fill it with five columns of data.
(there are two Boolean elements at the beginning of your data Vector)
Fiona Healy
Greenhorn
Joined: Jan 27, 2005
Posts: 21
posted
0
it doesnt make a difference. This is just me messin with the code and experimenting with different options...still gettin the same silly error..but thanx anyway
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
this post from a couple of days ago might be worth a look
There is still some issue with passing vectors as opposed to String[] which is something i need to do. I read on a forum that you need to pass the model a Vector of Vectors??? How would you make a vector of vectors for the column names?
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
>I read on a forum that you need to pass the model a Vector of Vectors??? >How would you make a vector of vectors for the column names?
I think the vector of vectors is the row data, not the column names (single vector)
your row data 'vector of vectors' would probably be something like this
definitionData = new Vector(); //definitionData.add(new Boolean(true));//removed
//loop through vector of report definition objects ReportDefinitionPOJO pojo = new ReportDefinitionPOJO(); for(Enumeration e = reports.elements();e.hasMoreElements() { pojo = (ReportDefinitionPOJO)e.nextElement(); //holds data in an individual row Vector vec = new Vector(); vec.add(0, new Boolean(false)); vec.add(pojo.getName()); vec.add(pojo.getRequester()); vec.add(pojo.getDestination()); definitionData.add(vec); }
jefff willis
Ranch Hand
Joined: Sep 29, 2004
Posts: 113
posted
0
cut and paste this code to see an example that runs: