java - Erratic auto-scrolling in JList -
i'm trying create jlist allows re-order items in list dragging them. working ok, except auto-scrolling behavior jerky , erratic. when grab item in list , drag bottom of list, expect scroll smoothly , continuously, scrolls few pixels , stops. if jiggle mouse cursor around edge of jlist, continues scrolling few pixels @ time, not acceptable behavior.
does have suggestions on how fix this?
in case matters, i'm running java 6 on mac os x 10.8.3.
import javax.swing.*; import java.awt.*; import java.awt.datatransfer.stringselection; import java.awt.datatransfer.transferable; public class draggablejlist { public static void main(string[] args) { eventqueue.invokelater( new runnable() { public void run() { int count=200; string[] elements = new string[count]; for(int n=0; n<count; n++ ) { elements[n] = string.valueof( n ); } jlist list = new jlist( elements ); list.setdragenabled( true ); //if disable line, smooth scrolling, can't drag items re-order them list.setdropmode( dropmode.insert ); final transferhandler transferhandler = new transferhandler() { @override public int getsourceactions( jcomponent c ) { return transferhandler.move; } @override protected transferable createtransferable( jcomponent c ) { return new stringselection( "hey there" ); } }; list.settransferhandler( transferhandler ); jscrollpane scrollpane = new jscrollpane( list ); jframe frame = new jframe(); jpanel borderpanel = new jpanel(); borderpanel.add( scrollpane ); borderpanel.setborder( borderfactory.createemptyborder( 40, 40, 40, 40 ) ); frame.setcontentpane( borderpanel ); frame.pack(); frame.setvisible( true ); } } ); } }
did searching , turns out known bug:
Comments
Post a Comment