Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drag and Drop Objects (Serialized)

Status
Not open for further replies.

Toyman

Programmer
Jun 19, 2001
68
GB
Hi

I can't seem to find a good solution on Draggin and Dropping of objects.....

That is .....

I've got a class (Non Swing Component)

I want to be able to drag and drop the object of the created class and not the text only.

Please don't point me to sites where I can read on this unless there is simple code on how to do this. I've spend a week reading throught sites (Including Sun's) but did't get what I'm looking for.

Thanks


Toyman
VB / Java Programmer
carel_dutoit@yahoo.co.uk
 
I'm not sure what you are suggesting really makes sense. What kind of "object" do you want to "drag and drop". For example, if it is a java.sql.Connection object, or an RMI interface, then this just makes no sense. If it is something like an image object, then how do you propose to update the UI to render that image ? What about a File object. How would you "drag and drop" that ?

--------------------------------------------------
Free Database Connection Pooling Software
 
Okay let me explain....

I want to mainly do it for database type applications...
This class is used to populate a list op personnel in a JList.... I create a Object for each person in my personnel file... then add it to a Vector which goes into the JList DefaultListModel.... this will display all my personnel through the toString() method....

This is my Class

public class MyClass{

private String personnelId;
private String name;
private String surname;

Public MyClass(String Id,String name,String surname){
Blah blah set all the members .....
}

public String toString(){
return surname + ", " + name;
}

public String getPersonnelID(){
return personnelId;
}
}

Okay so this is the class... I did this freehand so please no comments on syntax .... :)

So every item in my JList is actually an Object of this class... I can now drag this to and DropListener which will receive the toString() method as text...
But wat I realy want to do is the pass the object(reference to object) to the DropListener so that I can
perform a getPersonnelId which is use to retrieve information on the personnel.....or any other method that is related to the personnel class.....

Even without an application being a non database application... I can think of a million senarios where one want to drag a reference of an object or the object self.
After all ... Java is Object driven and not text :)
Even Visual Basic can Use Objects as for Drag and Drop !!!!

Thanks for the reply anywhy !!!!!

 
Well, I know you said "don't give me any links from the web", but these two links, after some work, I think will be able to drive the kind of thing you wish to do :


It seems as if it may be quite tricky, but possible ...

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top