comp.lang.ada
 help / color / mirror / Atom feed
From: "Marc A. Criley" <mcqada@earthlink.net>
Subject: JGNAT, TreeModels, and interfaces
Date: Fri, 16 Mar 2001 13:31:27 GMT
Date: 2001-03-16T13:31:27+00:00	[thread overview]
Message-ID: <3AB2080E.7C0DFB53@earthlink.net> (raw)

With JGNAT 1.1p on RedHat Linux 6.2...

I've built a JTree structure, and now I need to update one of its leaves
programmatically, i.e., by the program, not through user editing.

Having generated the new leaf node, I need to inform the tree to display
it.  It appears the way to do this is using the "nodeChanged" method in
the javax.swing.tree.defaultTreeModel class.

The Ada binding to this method is:

   procedure nodeChanged
     (This : access Typ; 
      P1_TreeNode : access javax.swing.tree.TreeNode.Typ'Class);

where "Typ" is the DefaultTreeModel tagged type.

So besides the new node, I also need to specify an instance of the
DefaultTreeModel.

Here's where the problem comes in.

To me, it seems that I ought to get the tree model from the tree using
the getModel method from javax.swing.jtree, since what I'm working with
is a Jtree.

The method looks like this:

   function getModel
      (This : access Typ)
       return javax.swing.tree.TreeModel.Ref;

I pass in my Jtree and get back a handle to a TreeModel...which is _not_
a DefaultTreeModel.  TreeModel is in fact a Java interface that
DefaultTreeModel implements.

I can't figure out how to get that TreeModel into a form that I can pass
to a DefaultTreeModel procedure.  In Java, it appears that a typecast is
performed.  But this won't fly in Ada because these two classes are
independent of one another and so can't be converted.

A DefaultTreeModel implements the TreeModel interface, so if I was
getting a DefaultTreeModel I could easily get at its TreeModel
capabilities, but I'm getting the TreeModel and somehow need to upgrade
that to a DefaultTreeModel instead.

Suggestions are welcome :-)

Marc A. Criley



             reply	other threads:[~2001-03-16 13:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-16 13:31 Marc A. Criley [this message]
2001-03-18 22:08 ` JGNAT, TreeModels, and interfaces Marc A. Criley
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox