Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #37573

Re: How do you update a component when you leave on a drag?

Newsgroups comp.lang.java.programmer
Date 2017-10-16 06:07 -0700
References <255e35fe-5f4f-4916-89c5-f5d07b74ca3c@googlegroups.com> <orr2pd$219$1@dont-email.me> <08b10dcc-e61e-4f55-a0cb-878d64493104@googlegroups.com>
Message-ID <77d5a7ae-33a3-470f-99cd-1fa68c60c6e2@googlegroups.com> (permalink)
Subject Re: How do you update a component when you leave on a drag?
From Eric Douglas <e.d.programmer@gmail.com>

Show all headers | View raw


On Friday, October 13, 2017 at 4:02:32 PM UTC-4, Eric Douglas wrote:
> > Do you want to update it while you are still dragging?  I'm not sure but 
> > have you tried calling validate() based on the mouse position?  You may 
> > still have problems in that the EDT is blocked by your drag operation.
> > 

My TransferHandler doesn't seem to be aware of when it leaves the JTable, only processing methods while it's over the JTable, so I traced through some of the javax.swing.TransferHandler methods which led me to this.
My JTable has a class variable INSERTROW which my TableUI checks to draw a red line between rows to show where to drop.  I tested overriding the following method which seems to work.  For the test I just made a new anonymous listener, though I'm thinking I should keep one as a private static variable.


     @Override
     public void setDropTarget(final DropTarget dt) {
          super.setDropTarget(dt);
          if (dt != null) {
               try {
                    dt.addDropTargetListener(new DropTargetListener() {

                         @Override
                         public void dragEnter(DropTargetDragEvent dtde) {
                         }

                         @Override
                         public void dragOver(DropTargetDragEvent dtde) {
                         }

                         @Override
                         public void dropActionChanged(DropTargetDragEvent dtde) {
                         }

                         @Override
                         public void dragExit(DropTargetEvent dte) {
                              INSERTROW = -1;
                              fireTableDataChanged();
                         }

                         @Override
                         public void drop(DropTargetDropEvent dtde) {
                         }
                         
                    });
               } catch (TooManyListenersException e) {
                    // ??
                    e.printStackTrace();
               }
          }
     }

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

How do you update a component when you leave on a drag? Eric Douglas <e.d.programmer@gmail.com> - 2017-10-13 10:42 -0700
  Re: How do you update a component when you leave on a drag? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-10-13 14:04 -0500
    Re: How do you update a component when you leave on a drag? Eric Douglas <e.d.programmer@gmail.com> - 2017-10-13 13:02 -0700
      Re: How do you update a component when you leave on a drag? Eric Douglas <e.d.programmer@gmail.com> - 2017-10-16 06:07 -0700

csiph-web