使用JavaFX和Event获取鼠标位置(Getting a mouse position with JavaFX and Event)
我正试图在我的JavaFX应用程序中获得鼠标单击的位置。 我有一个EventHandler:
EventHandler<Event> mouseHandler = new EventHandler<Event>() { @Override public void handle(Event event) { String eType = event.getEventType().toString(); if(eType.equals("MOUSE_PRESSED")){ //mouse position } } };
这是在鼠标按下,释放和拖动时调用的。 我无法从
Event
获取鼠标的位置,当我尝试将EventHandler<Event>
更改为EventHandler<MouseEvent>
我收到消息Type paremeter 'java.awt.event.MouseEvent' is not within it's bounds; should extend to 'javafx.event.Event'
Type paremeter 'java.awt.event.MouseEvent' is not within it's bounds; should extend to 'javafx.event.Event'
。如何将其移至MouseEvents?
I'm trying to get the position of a mouse click in my JavaFX application. I have an EventHandler as so:
EventHandler<Event> mouseHandler = new EventHandler<Event>() { @Override public void handle(Event event) { String eType = event.getEventType().toString(); if(eType.equals("MOUSE_PRESSED")){ //mouse position } } };
which is called on mouse press, release and drag. I'm unable to get the position of the mouse from
Event
and when I try and changeEventHandler<Event>
toEventHandler<MouseEvent>
I get the messageType paremeter 'java.awt.event.MouseEvent' is not within it's bounds; should extend to 'javafx.event.Event'
.How can I move this over to MouseEvents?
原文:https://stackoverflow.com/questions/30985634
最满意答案
如果您在google
jpsgcs.alun.random.Sampling
搜索,则会收到有关此Sampling
类的一些损坏的链接。 此外,如果你在这里浏览,你可以看到在罐子里,你可以下载,甚至没有像random
这样的包。 所以,可能由于某些原因被删除了...也许这个Sampling类被删除了,因为不能正常工作? 我可以建议你与编写这个库的人取得联系。If you search in google
jpsgcs.alun.random.Sampling
, you get some broken links about thisSampling
class. Moreover, if you browse here you can see that in the jar, that you can download, there is no more even such a package likerandom
. So, probably that was removed for some reasons ... Maybe this Sampling class was removed because not working properly? I can just suggest you to get in touch with somebody that wrote this library.
相关问答
更多-
drawRect不是每次都调用(drawRect not called everytime)[2023-12-10]
问题似乎是iOS 9以后的特定问题。 我也可以在其他设备中复制它。 问题似乎与UIWindow手势识别器有关。 当我检查你的(@iphonic)示例代码时,我发现如果我在该特定位置点击并按住一秒钟,那么drawRect将被调用:)。 所以在我看来,那些地方的delay in touches有所delay in touches 。 所以我开始调试不同地方的触摸,发现_UISystemGestureGateGestureRecognizer这是一个私有类在这些区域有不同的属性,我做的是我只是通过附加到UIWin ... -
您可以看到的效果是视错觉。 您可以通过对颜色进行分级来使其可见。 请参阅stackoverflow问题的答案问题在glsl es 2.0,Gamemaker Studio 2.0中获取渐变方块 。 要获得更好的结果,您可以使用着色器平滑地更改渐变,从视图中间的圆形(或椭圆)渐变到视图边框处的方形渐变: void mainImage( out vec4 fragColor, in vec2 fragCoord ) { // Normalized pixel coordinates (from 0 to ...
-
每次我尝试运行我的Junit测试用例时都会出现NullPointer异常(NullPointer Exception everytime I try to run my Junit Test Case)[2021-10-03]
您将其作为纯单元测试运行,没有Spring上下文。 因此,存储库将不会自动装配。 您应该能够通过在测试类的顶部添加一些注释来解决这个问题。 如果使用Spring Boot,那么像下面这样的东西应该可以工作,让Spring Boot做所有艰苦的工作: @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = MyApplication.class) 您也可以加载Spring @Configuration ... -
这不行 w=w.toUpperCase().replace(w.substring(1), w.substring(1).toLowerCase()) 因为w.substring(1)与w.toUpperCase 。 基本上你有...... w = "MY NAME IS ALEX".replace("y Name Is Alex", "y name is alex"); 正如您所看到的,没有什么可以匹配String 。 大写字符与提供的String值不匹配 你的双线方法更像是...... w=w.t ...
-
如果您在google jpsgcs.alun.random.Sampling搜索,则会收到有关此Sampling类的一些损坏的链接。 此外,如果你在这里浏览,你可以看到在罐子里,你可以下载,甚至没有像random这样的包。 所以,可能由于某些原因被删除了...也许这个Sampling类被删除了,因为不能正常工作? 我可以建议你与编写这个库的人取得联系。 If you search in google jpsgcs.alun.random.Sampling, you get some broken links ...
-
我明白,“表单”是指电子表格,即工作簿,文档和文件,因为在同一电子表格上的多个工作表上使用脚本不需要为每个脚本授权脚本,因为您看到“大量用于授予权限的条目“ 我也明白你的脚本是在一个脚本项目上绑定到一个电子表格。 当我们制作一个电子表格的副本时,它将包含一个到它所绑定的脚本项目的副本。 新的电子表格及其有限的项目,因为它们是不同的文件和Google的政策,运行脚本的授权是由脚本项目给出的。 避免拥有相同代码的许多副本并且必须授权他们每个人的方法是使用附加组件,这就是我投票选择在所有电子表格中重复使用脚本来关 ...
-
看起来你走在正确的轨道上。 让我们假装我运行Do-PromptTask,选择任务1,然后单击运行... 来自Prompt-SelectionList的$ result变量将传递回Switch语句,此时超出范围 。 该开关正在完成其工作并匹配条件,然后打印$ task1_exec,但此时$ result无用。 如果要将$ task1_exec存储为变量,则需要设置与其相等的值。 但是,我会说你可以在switch语句中对它进行操作而不将其存储在变量中,如果这是有意义的话。 更少的代码方法...... f ...
-
长时间你可以表示-9,223,372,036,854,775,808到+9,223,372,036,854,775,807 ( 来源 )之间,因此很快通过该范围的阶乘就会出现错误。 With long you can represent between -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 (source)so as soon the factorial pass that range you start to get errors ...
-
您可以使用第一次滚动大于或等于250时设置的标志,并在滚动小于250时重置它(这样如果用户向下滚动,向上和向下滚动,它仍然会再次触发)。 $(document).ready(function(){ var flag = false; function someFunction() { $(".someContent .someYellowOverlay").toggleClass("someAnimation").delay(250).queue(function(next ) { $ ...
-
每次访问页面时,setInterval()都会触发另一个间隔(setInterval() triggers another interval everytime page is visited)[2022-04-17]
尝试将代码更改为setTimeout,如下所示: //ensure interval variable are accessible var myInterval = null; var autoScroll = function() { jQuery.fn.fullpage.moveSectionDown() }; window.laytheme.on("newpageshown", function(layoutObj, type, obj){ if(obj.id === 11){ ...