Article View: borland.public.jbuilder.java.swing
Article #9843Re: Message box from drag and drop
From: Sébastien
Date: Sat, 08 Jan 2000 00:00
Date: Sat, 08 Jan 2000 00:00
54 lines
2486 bytes
2486 bytes
You must use a thread.
It is the only solution.
When the drop is finished, start your thread.
"Mikhail M.Mizels" a �crit :
> Hello All!
>
> I have following problem: I implement Drag and Drop in my program and I need
> to show message box when drop occured, but when I call
> JOptionPane.showMessageDialog() my program hangs.
>
> This is an example which I have downloaded from java.sun.com
>
> public void drop (DropTargetDropEvent event) {
>
> try {
> Transferable transferable = event.getTransferable();
>
> // we accept only Strings
> if (transferable.isDataFlavorSupported (DataFlavor.stringFlavor)){
>
> event.acceptDrop(DnDConstants.ACTION_MOVE);
> String s = (String)transferable.getTransferData
> DataFlavor.stringFlavor);
> addElement( s );
> event.getDropTargetContext().dropComplete(true);
>
> // THIS IS MY CODE INSERTION
> JOptionPane.showMessageDialog(this, "test", "test",
> JOptionPane.INFORMATION_MESSAGE);
> // THIS IS END OF MY CODE INSERTION
> }
> else{
> event.rejectDrop();
> }
> }
> catch (IOException exception) {
> exception.printStackTrace();
> System.err.println( "Exception" + exception.getMessage());
> event.rejectDrop();
> }
> catch (UnsupportedFlavorException ufException ) {
> ufException.printStackTrace();
> System.err.println( "Exception" + ufException.getMessage());
> event.rejectDrop();
> }
> }
>
> This also hangs.
>
> I tried to use SwingUtilities.invokeLater() to show message but it has the
> same effect. What am I doing wrong?
Technical Details
Message-ID:
<38770ECB.8A9C1E6C@polydeme.fr>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<855rd2$s2t21@bornews.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 111d45,4b45373640cb09ef X-Google-Attributes: gid111d45,public From: Sébastien <smignard@polydeme.fr> Subject: Re: Message box from drag and drop Date: 2000/01/08 Message-ID: <38770ECB.8A9C1E6C@polydeme.fr> X-Deja-AN: 569916894 Content-Transfer-Encoding: 8bit References: <855rd2$s2t21@bornews.borland.com> To: "Mikhail M.Mizels" <mizels@cttcomp.rricc.tsi.ru> X-Accept-Language: fr Content-Type: text/plain; charset=iso-8859-1 X-Complaints-To: abuse@fr.uu.net X-Trace: jaydee.iway.fr 947326598 14226 194.98.147.33 (8 Jan 2000 10:16:38 GMT) Organization: POLYDEME Mime-Version: 1.0 NNTP-Posting-Date: 8 Jan 2000 10:16:38 GMT Newsgroups: borland.public.jbuilder.java.swing