PDF的按住鼠标左键移动背景的效果,用JAVA怎么实现,我下边的代码,实现了一部分,但效果不理想,没有完全实现,动作跟我想要的不一样,移动幅度太大了,大家帮忙看看,
/**
* PDFの移動背景図
* @param location Point
*/
public void setVisibleRect(Point location) {
Rectangle rect = getVisibleRect();
if( lastPoint!=null && lastPoint.equals( location )== false ) {
int px = location.x - lastPoint.x;
int py = location.y - lastPoint.y;
rect.x += px;
rect.y += py;
lastPoint = location;
}
if( lastPoint==null ){
lastPoint = location;
}
scrollRectToVisible(rect);
}
上边的代码直接放在PANEL里边直接调用就可以了,有没有朋友在此基础上帮助下,
/**
* PDFの移動背景図
* @param location Point
*/
public void setVisibleRect(Point location) {
Rectangle rect = getVisibleRect();
if( lastPoint!=null && lastPoint.equals( location )== false ) {
int px = location.x - lastPoint.x;
int py = location.y - lastPoint.y;
rect.x += px;
rect.y += py;
lastPoint = location;
}
if( lastPoint==null ){
lastPoint = location;
}
scrollRectToVisible(rect);
}
上边的代码直接放在PANEL里边直接调用就可以了,有没有朋友在此基础上帮助下,
rect.y += py;
改成
rect.x += -px;
rect.y += -py;
方向对了,但是背景图片老是闪,还是有问题.