[Java-gnome-developer] TreeView doesn't show with Glade
                
                Brought to you by:
                
                    afcowie
                    
                
            
            
        
        
        
    | 
      
      
      From: Luis M. V. <lui...@gm...> - 2011-02-17 18:36:06
      
     | 
| Hi!
I have a problem with the TreeView and Glade
I'm using:
libjava-gnome 4.0.14
Glade 3.6.7
Eclipse 3.6.1
Ubuntu 10.04
For example, in the next code, where I don't use glade, the TreeView show
the information of TreeModel
---------------8<---------------------
public class ExampleWithoutGlade {
    public ExampleWithoutGlade() {
     Window win = new Window();
        DataColumnString placeName = new DataColumnString();
        ListStore model = new ListStore(new DataColumn[] { placeName });
        TreeIter row = model.appendRow();
        model.setValue(row, placeName, "Line 1");
        row = model.appendRow();
        model.setValue(row, placeName, "Line 2");
        row = model.appendRow();
        model.setValue(row, placeName, "Line 3");
        TreeView treeview = new TreeView(model);
 win.add(treeview);
        TreeViewColumn vertical = treeview.appendColumn();
        vertical.setTitle("Lines");
        CellRendererText renderer = new CellRendererText(vertical);
        renderer.setMarkup(placeName);
        win.showAll();
        win.connect(new Window.DeleteEvent() {
            public boolean onDeleteEvent(Widget source, Event event) {
                Gtk.mainQuit();
                return false;
            }
        });
    }
    public static void main(String[] args) {
        Gtk.init(args);
        new ExampleWithoutGlade();
        Gtk.main();
    }
}
----------------------------------------
However, when I use the Glade interface, the TreeView doesn't show with the
information of TreeModel
---------------8<---------------------
public class ExampleWithGlade {
    public ExampleWithGlade() throws FileNotFoundException {
     XML xmlWin = Glade.parse("rsc/example.glade", "win");
     XML xmlTreeView = Glade.parse("rsc/example.glade", "treeview");
     Window win = (Window) xmlWin.getWidget("win");
     TreeView treeview = (TreeView) xmlTreeView.getWidget("treeview");
        DataColumnString placeName = new DataColumnString();
        ListStore model = new ListStore(new DataColumn[] { placeName });
        TreeIter row = model.appendRow();
        model.setValue(row, placeName, "Line 1");
        row = model.appendRow();
        model.setValue(row, placeName, "Line 2");
        row = model.appendRow();
        model.setValue(row, placeName, "Line 3");
        treeview.setModel(model);
         TreeViewColumn vertical = treeview.appendColumn();
        vertical.setTitle("Lines");
        CellRendererText renderer = new CellRendererText(vertical);
        renderer.setMarkup(placeName);
        win.showAll();
        win.connect(new Window.DeleteEvent() {
            public boolean onDeleteEvent(Widget source, Event event) {
                Gtk.mainQuit();
                return false;
            }
        });
    }
    public static void main(String[] args) throws FileNotFoundException {
        Gtk.init(args);
        new ExampleWithGlade();
        Gtk.main();
    }
}
----------------------------------------
The glade file:
Preferences: libglade + gtk+ 2.12
---------------8<---------------------
<?xml version="1.0"?>
<glade-interface>
  <!-- interface-requires gtk+ 2.12 -->
  <!-- interface-naming-policy project-wide -->
  <widget class="GtkWindow" id="win">
    <property name="title" translatable="yes">.</property>
    <child>
      <widget class="GtkTreeView" id="treeview">
        <property name="visible">True</property>
        <property name="can_focus">True</property>
      </widget>
    </child>
  </widget>
</glade-interface>
----------------------------------------
I don't undestand the reason of this issue.
Could you help me?
Best regards
 |