Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8088234

JFXPanel: Assertion error when building a Drag and Drop capable TableView in embedded JFXPanel

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • tbd
    • 8u11
    • javafx
    • Windows 7, JDK 8u11, Netbeans based SWING application with embedded JavaFX

      I wrote code for a TableView that will allow rows to drag and drop. Works great as a standalone JavaFX application. However, it doesn't work in an embedded JFXPanel for work in a Swing app. I want to integrate it with my Swing app, so I can't use it as a standalone.

      The error is in the JavaFX code itself, which isn't giving me a whole lot to go on.


      java.lang.AssertionError
      at javafx.embed.swing.SwingDnD.startDrag(SwingDnD.java:261)
      at javafx.embed.swing.SwingDnD.access$1000(SwingDnD.java:73)
      at javafx.embed.swing.SwingDnD$4$1.run(SwingDnD.java:249)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:744)
      at java.awt.EventQueue.access$400(EventQueue.java:97)
      at java.awt.EventQueue$3.run(EventQueue.java:697)
      at java.awt.EventQueue$3.run(EventQueue.java:691)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:714)




      Here is my code that creates the handler in a customized TableView class



      private EventHandler<MouseEvent> createDragDetectedHandler(
          final TableCell<ReportSelectedItem, String> cell) {
          return new EventHandler<MouseEvent>() {
              @Override
              public void handle(MouseEvent event) {
                  try {

                      Dragboard db = cell.startDragAndDrop(TransferMode.MOVE);
                      ClipboardContent content = new ClipboardContent();
                      content.putString(String.valueOf(cell.getIndex()));
                      WritableImage snapshot = cell.getTableRow().snapshot(new SnapshotParameters(), null);
                      db.setDragView(snapshot);
                      db.setContent(content);
                  } catch (AssertionError ex) {
                      ex.printStackTrace();
                  }
              }
          };
      }


      The exception is thrown from this line: Dragboard db = cell.startDragAndDrop(TransferMode.MOVE);

      So, I noticed that it's calling SwingDnD in my embedded instance, but GlassScene in the stand alone. So it's using different code for the Drag and Drop functionality.

            psadhukhan Prasanta Sadhukhan
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: