🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #9841

Message box from drag and drop

#9841
From: Mikhail M.Mizels
Date: Sat, 08 Jan 2000 00:00
47 lines
1976 bytes
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: <855rd2$s2t21@bornews.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,4b45373640cb09ef,start
X-Google-Attributes: gid111d45,public
From: "Mikhail M.Mizels" <mizels@cttcomp.rricc.tsi.ru>
Subject: Message box from drag and drop
Date: 2000/01/08
Message-ID: <855rd2$s2t21@bornews.borland.com>
X-Deja-AN: 569756987
Organization: Another Netscape Collabra Server User
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
Newsgroups: borland.public.jbuilder.java.swing