Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Drag and Drop

 
Jeremy Hooie
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to perform Drag and Drop operations from a JTree to a JList, but when I move something from the tree to the list, I receive the class and a memory address instead of the value(javax.swing.tree.DefaultTreeSelectionModel xxxxxxx [[null, Parent, Node]@xxx]). DnD from JList to JList or JTextArea to JTextArea works fine. Any suggestions?
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you drop the item from your tree, make sure you are dropping the data into a DefaultListModel, otherwise it will print the jargon you were speaking of.
Regards

 
Jeremy Hooie
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's what I've got. The reference to the object is of type Object and I try to get the String interpretation of it.
public void addElement(Object s)
{
((DefaultListModel)getModel()).addElement(s.toString());
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic