JTree selectionModel

50 views
Skip to first unread message

hrle

unread,
Feb 12, 2012, 1:00:48 PM2/12/12
to JavaBuilders
Hi all,

I see I can specify selectionModel for JTree but I am not succesfull
in doing so. I don't know what value can I set for this property.
Whatever I set, "org.javabuilders.BuildException: Failed to set
JTree.selectionModel = 1" is recieved.

Basically, I want to set SINGLE_TREE_SELECTION for my tree. Can
anybody help me?

hrle

unread,
Feb 12, 2012, 2:03:49 PM2/12/12
to JavaBuilders
Just to make correction, the value that I set for selectionModel in
YAML was thrown in exception as an invalid argument. It is not
hardcoded ofcourse (the above is just an example of value). Didn't
read my question once again before I posted it. :)

Jacek Furmankiewicz

unread,
Feb 12, 2012, 3:20:13 PM2/12/12
to javabu...@googlegroups.com
Hi, could you attach a sample YAML? thanks


--
You received this message because you are subscribed to the Google Groups "JavaBuilders" group.
To post to this group, send email to javabu...@googlegroups.com.
To unsubscribe from this group, send email to javabuilders...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/javabuilders?hl=en.


hrle

unread,
Feb 13, 2012, 12:23:30 AM2/13/12
to JavaBuilders
Here is my YAML:

JFrame(name=mainWindow, title=mainWindow.title, iconImage=/sample/
icon.png, size=520x440, locationRelativeTo=null,
defaultCloseOperation=exitOnClose):
- JMenuBar:
- JMenu(name=fileMenu, text=menu.file):
- JMenuItem(name=fileMenuOpen, text=menu.file.open, icon=/
sample/open.png, onAction=onFileOpenMenuClick)
- JMenuItem(name=fileMenuClose, enabled=false,
text=menu.file.close, icon=/sample/close.png,
onAction=onFileCloseMenuClick)
- JMenuItem(name=fileMenuSave, enabled=false,
text=menu.file.save, icon=/sample/save.png,
onAction=onFileSaveMenuClick)
- JSeparator()
- JMenuItem(name=fileMenuExit, text=menu.file.exit, icon=/
sample/exit.png, onAction=onFileExitMenuClick)
- JMenu(name=helpMenu, text=menu.help):
- JMenuItem(name=fileMenuAbout, text=menu.file.about,
icon=/sample/about.png)
- JPopupMenu(name=contextMenu):
- JMenuItem(name=contextMenuAddProfile,
text=context.profile.add, icon=/sample/add.png)
- JMenuItem(name=contextMenuDeleteProfile,
text=context.profile.delete, icon=/sample/remove.png, enabled=false)
- JSplitPane(name=splitPane, orientation=horizontalSplit,
resizeWeight=0.35):
- JScrollPane(name=policyTreeScrollPane, groupTitle=policies):
PolicyTree(name=policyTree, showsRootHandles=true,
rootVisible=false, onSelection=onPoliciesTreeNodeSelection,
selectionModel=1)
- JPanel(name=detailsPanel, groupTitle=details):
- MigLayout(layoutConstraints="insets 0 0 0 0",
columnConstraints="grow, push, fill", rowConstraints="grow, push,
fill"):

The PolicyTree class is extended from JTree. But I also tried setting
selectionModel on plain vanilla JTree but it also gives me such
exception.
I tried setting selectionModel value to everything that crossed my
mind (SINGLE_TREE_SELECTION, some integer, string like "single"...)
also with no avail.

Jacek Furmankiewicz

unread,
Feb 14, 2012, 3:42:58 PM2/14/12
to JavaBuilders
From what I see, JRree.setSelectionModel() requires an instance of a
TreeSelectionModel interface. It is not an enum or integer or
anything.

From the tutorial, they basically want you to do:

tree.getSelectionModel().setSelectionMode
(TreeSelectionModel.SINGLE_TREE_SELECTION);

it's the 'getSelectionModel()' + 'setSelectionMode()' on that existing
instance tat we do not handle. It will need a custom code handler to
provide that.
Pls log an issue in Google Code and I can probably whip up a fix for
you reasonably quickly,

In the meantime your only option is to get a handle to your PolicyTree
on the Java side and do it manually there.

hrle

unread,
Feb 16, 2012, 1:56:45 AM2/16/12
to JavaBuilders
Thank you Jacek. It is not a problem, I already set selection model in
Java. But anyway, it would be great if this can be set in YAML.

Issue created.
Link: http://code.google.com/p/javabuilders/issues/detail?id=146
Reply all
Reply to author
Forward
0 new messages