Article View: borland.public.jbuilder.java.language
Article #16540Re: newbe: Drag and Drop
From: Vasudevan Srinivasan
Date: Wed, 10 Feb 1999 00:00
Date: Wed, 10 Feb 1999 00:00
48 lines
2197 bytes
2197 bytes
Hi,
if you are using jdk1.1.x: i dont think drag n drop is implemented. you have
also not mentioned whether you are dragging items intra-component or
inter-component;
assuming the later, in your situation what i would do is:
//This is just a code to direct you - may not work "as is"; you may have to
tweak n trim here and there
//Step1. declare two components as memebers
Object source, target;
boolean bMousePressed=false;
//Step2: capture mousePressed of source
sourceComponent.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(MouseEvent e) {
bMousePressed=true;
source = e.getSource();
}
});
//Step3: capture mouseRelease in target
tgtComponent.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(MouseEvent e) {
if (bMousePressed) {
target = e.getSource();
// what ever you want to do
}
}
});
it is said the jdk1.2 supports dragndrop but no idea how far and how good
Goodluck
Vasu
Ones Self wrote:
> I want to use drag and drop in my java application, the problem is I
> can't find an event
> that holds both the dropped component and the component which the former
> got drop on.
> being a former C++Builder user I looked for something like an onDragDrop
> event, but
> could not find one. when I use the mouseReleased event I get a reference
> to the component that was dragged and drop but not I can't tell which
> component got drop
> on. what I need is an event which holds both these references. any help
> would be appreciated. and a bit of code would be too.
Technical Details
Message-ID:
<36C1FD77.9C7652EA@netrisk.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<36C09E34.63CBD27A@usa.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,d37fb261fcea0d84 X-Google-Attributes: gidf74b3,public From: Vasudevan Srinivasan <vasudevan@netrisk.com> Subject: Re: newbe: Drag and Drop Date: 1999/02/10 Message-ID: <36C1FD77.9C7652EA@netrisk.com> X-Deja-AN: 442970505 Content-Transfer-Encoding: 7bit References: <36C09E34.63CBD27A@usa.net> To: Ones Self <oneself@usa.net> Content-Type: text/plain; charset=us-ascii Organization: NetRisk Inc Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language