score:0

It seems (at least on OS X), that the wheel events are buffered and dispatched only after the DnD gesture is complete. Here is my try:

import javax.swing._

val d = Array.fill(1000)(Array[AnyRef]((math.random * 1000).toInt.toString))
val t = new JTable(d, Array[AnyRef]("A")) {
  override def processMouseWheelEvent(e: java.awt.event.MouseWheelEvent): Unit = {
    println(s"Wheel: ${e.getID}")
    super.processMouseWheelEvent(e)
  }
  def enableEventsP(e: Long): Unit = enableEvents(e)
}
t.setDragEnabled(true)
t.enableEventsP(java.awt.AWTEvent.MOUSE_WHEEL_EVENT_MASK)

val f = new JFrame
f.getContentPane.add(new JScrollPane(t), java.awt.BorderLayout.CENTER)
f.pack()
f.setVisible(true)

When I scroll the wheel while dragging and then release the mouse, the wheel events are delivered.


You may want to override the autoscroll behaviour of the JTable to make it faster, I guess. This is done in DropTarget as far as I can see. I found this example.


Related Query

More Query from same tag