mousemove不好用java,mouse的

http://www.itjxue.com  2023-01-23 17:28  来源:未知  点击次数: 

我要在VB里的一张图片跟着鼠标移动而移动,但用mousemove图片总会卡住,不那么灵活....还有其它方法没??

1.

把图片左、上留下一些透明区域。这些透明区域就作为了感应区域。这样可以减小卡住几率。毕竟鼠标经过它们不触发事件不大现实。

2.

干脆用API,timer不断获取鼠标坐标 然后调整位置(最好记录下上次位子,如果不同则移动。

如何在网页上实现鼠标悬停使图片放大功能,好像java的class可以,不知道怎么实现的呢?

这有一个例子,你可以参考一下:

html显示原始图片

a href="../images/4.jpg" class="preview" title="疯狂滑雪"img src="../images/4s.jpg" //a

a href="../images/photo_1.jpg" class="preview" title="奥运吉祥物"img width="100" height="75" src="../images/photo_1_small.gif"//a

以下是jQuery实现图片预览的主要过程。

hover()事件

xOffset = 10;

yOffset = 30;

$("a.preview").hover(function(e){

this.t = this.title;

this.title = "";

var c = (this.t != "") ? "br/" + this.t : "";

$("body").append("p id='preview'img src='"

+ this.href +"' alt='Image preview' /"+ c +"/p");

$("#preview")

.css("top",(e.pageY - xOffset) + "px")

.css("left",(e.pageX + yOffset) + "px")

.fadeIn("fast");

},function(){

this.title = this.t;

$("#preview").remove();

});

程序中首先找到预览图片,光标移动到某个图片上时,将此图片的预览图片添加到body中,将id命名为preview。preview开始是不可见的,.css()为图片指定了位置,.fadeIn()最终显示预览图片。当光标离开图片时,将添加的预览图片使用remove()方法移除。

使用mousemove()方法移动鼠标时移动预览

最后,当鼠标在图片上移动时,应该使用mousemove()方法将图片预览也进行移动。

$("a.preview").mousemove(function(e){

$("#preview")

.css("top",(e.pageY - xOffset) + "px")

.css("left",(e.pageX + yOffset) + "px");

});

jQuery实现图片预览的完整代码

this.imagePreview = function(){

xOffset = 10;

yOffset = 30;

$("a.preview").hover(function(e){

this.t = this.title;

this.title = "";

var c = (this.t != "") ? "br/" + this.t : "";

$("body").append("p id='preview'img src='"

+ this.href +"' alt='Image preview' /"+ c +"/p");

$("#preview")

.css("top",(e.pageY - xOffset) + "px")

.css("left",(e.pageX + yOffset) + "px")

.fadeIn("fast");

},function(){

this.title = this.t;

$("#preview").remove();

});

$("a.preview").mousemove(function(e){

$("#preview")

.css("top",(e.pageY - xOffset) + "px")

.css("left",(e.pageX + yOffset) + "px");

});

};

java中Robot类鼠标移动问题

每次移动鼠标前先mouseMove(负的屏幕宽像素值,负的屏幕高像素值),移动到左上角作为初始位置,再移动到想要的位置

请教java robot 问题.点击事件无效

Robot r = new Robot();

r.mouseMove(x, y);

r.delay(100) //你的鼠标移动和按下,几乎同时了,可能出现还没移到地方已经点下了哈

r.mousePress(InputEvent.BUTTON1_MASK);

r.delay(10);

r.mouseRelease(InputEvent.BUTTON1_MASK);

(责任编辑:IT教学网)

更多

推荐Flash教程文章