Java应用程序:通常不会执行mouseDragged事件 [英] Java Application : mouseDragged Event isn't Executed Often Enough

查看:151
本文介绍了Java应用程序:通常不会执行mouseDragged事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以使mouseDragged事件更频繁地调用(就我而言,绘制颜色?我需要它来进行平滑绘制,因为现在,如果移动得太快,它不会绘制我的全部路径另外,我有一个存储像素颜色的2D阵列,所以如果我尝试通过另一种方法来解决问题,这也是有问题的,这就是为什么我认为增加mouseDragged频率将是最好的选择

Is there a way to make the mouseDragged Event be called more Often ( In my Case, Drawing a Color? I need it for Smooth Drawing, because right now, if you move too fast, it doesn't Draw All my Path. Also, I have an 2D Array Storing the Color of the Pixel, so that's also Problematic if I try to solve by problem by another Way, that's why I thought Increasing the mouseDragged Frequency would be the Best thing to Do

谢谢

推荐答案

如果要平滑绘制,则可能需要插值如果您在(3,3)获得一个事件,而在(10,10)获得另一个事件,则可以计算出两者之间的斜率,然后遍历必须拖动鼠标才能从(3, 3)到(10,10)

If you want smooth drawing, you'd likely have to interpolate the data yourself. If you get an event at (3,3) and another at (10,10) you can figure the slope between the two, and iterate through the logical points that the mouse must have been dragged to get from (3,3) to (10,10)

我不知道强制mouseDragged更新更快的方法,例如,如果系统处于高负载下,或有人使用触摸屏,无论如何您都可能会跳起来。

I don't know of a way to force mouseDragged to update faster, and if, for instance the system was under high load, or someone used a touch screen, you might get huge jumps anyhow.

这篇关于Java应用程序:通常不会执行mouseDragged事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆