This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JavaFX and the fly likes Connecting two different tree nodes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JavaFX
Bookmark "Connecting two different tree nodes" Watch "Connecting two different tree nodes" New topic
Author

Connecting two different tree nodes

Kalidass Arumugam
Greenhorn

Joined: Jan 15, 2013
Posts: 4
All,

I am trying to create a gui with two trees, where i can connect/map a tree node with other tree node via a line using drag and drop

Its exactly like this in the url http://www.oracle.com/technetwork/articles/soa/schmutz-soa-eda-405955.html figure 3

Thanks,
Kalidass
Manuel Petermann
Ranch Hand

Joined: Jul 19, 2011
Posts: 175

What is your exact problem now?


Please correct my English.
Kalidass Arumugam
Greenhorn

Joined: Jan 15, 2013
Posts: 4
I wanted to know how to do it.
And any one who has done it already, please help me.
Manuel Petermann
Ranch Hand

Joined: Jul 19, 2011
Posts: 175

I don't think this is a trivial task but i have a basic idea what my approach would be.
You really need to tell us where your problem is.
1. You need to be able to connect two nodes.
2. You need to drag and drop those nodes.
3. you need to draw a line.
Which of those steps is giving you headaches?
Kalidass Arumugam
Greenhorn

Joined: Jan 15, 2013
Posts: 4
I am able to create a treeview with tree items.

Now i am facing difficulty in capturing the drop event on the tree item. In the below snippet not able to capture the drop event

treeView.setCellFactory(new Callback<TreeView<String>, TreeCell<String>>() {
@Override
public TreeCell<String> call(TreeView<String> stringTreeView) {
TreeCell<String> treeCell = new TreeCell<String>() {
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (item != null) {
setText(item);
}
}
};

treeCell.setOnDragDropped(new EventHandler<DragEvent>() {
public void handle(DragEvent event) {
System.out.println("dropped....");
}
});

treeCell.setOnDragDetected(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
System.out.println("dragged.....");
}
});

return treeCell;
}
});

and facing difficulty in maintaining the line connecting the tree items when i scroll the tree item.

Thinking of finding the graphic x an y layout properties of the tree item and drawing the line. But dont know how to capture the tree item scroll event.
Couldnt able to get anything from the net.



Kalidass Arumugam
Greenhorn

Joined: Jan 15, 2013
Posts: 4
Guys,

Little help here please.

Thanks,
Kalidass
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connecting two different tree nodes
 
Similar Threads
Expanding a Specific Node in JTree
JTree last selected path component is giving null
Identify the path of the node and insert in JTree.
recursion backwards?
jtree not scrolling to selected node