Re: [Java-gnome-developer] DataColumns and adding TreeView rows
Brought to you by:
afcowie
From: Sami W. <swa...@re...> - 2005-10-27 13:57:22
|
Hi Spyros, There is a very good tutorial on using TreeView on the java-gnome web page http://java-gnome.sourceforge.net/cgi-bin/bin/view/Main/TreeViewTutorial But from your email this is probably the most important part of the tutorial for you: Rather than creating an array of DataColumns, your code will be far easier to write if you create separate variables for each column: DataColumnBoolean ColIsChecked = new DataColumnBoolean(); DataColumnPixbuf ColFaceImage = new DataColumnPixbuf(); col3.addAttributeMapping(render3, CellRendererText.Attribute.TEXT, (DataColumnString)dc[3]); DataColumnString ColName = new DataColumnString(); ListStore ls = new ListStore( new DataColumn[] {ColIsChecked, ColFaceImage, ColName} ); Then later you can do this: ... ls.setValue(it, ColName , "Test"); ... > private void initTree(){ > list = (TreeView)glade.getWidget("listTreeView"); > > DataColumn[] dc = new DataColumn[4]; > for(int i = 0; i < 4; i++) col3.addAttributeMapping(render3, > CellRendererText.Attribute.TEXT, (DataColumnString)dc[3]); > dc[i] = new DataColumnString(); > > ListStore ls = new ListStore(dc); > tv.setModel(ls); This probably a mistake that happened when you were writing the email but shouldent it be list.setModel(ls) ? > * Sets a value in the data store. To display the data in the > widget, you > * need to associate the datablock with the renderer, using > methods of the > * {@link TreeViewColumn}. This just means calling addAttributeMaping which you already did here: col3.addAttributeMapping(render3, CellRendererText.Attribute.TEXT, (DataColumnString)dc[3]); I hope this helps :). Good luck, Sami Wagiaalla |