使用 Wacom 数位板进行 java Swing 调试令人头疼

发布于 2024-07-17 07:06:05 字数 891 浏览 12 评论 0原文

几年来,我在几个 Java 应用程序中一直遇到 Java Swing + 我的 Wacom Graphire 平板电脑的问题,现在我自己也遇到了这个问题。

我使用手写板来解决点击鼠标时出现的手腕问题,它在 Windows 下运行良好,除非我使用 Java 应用程序。 在 Java 应用程序中,单击笔无法正常工作。 (通常,该问题仅出现在文件选择对话框或树控件中。)数位板还配备了与同一数位板配合使用的无线鼠标,并且单击确实可以正常工作。

我不知道问题是出在 WACOM 驱动程序中还是 Windows 的 Java Swing 运行时中,或者两者兼而有之。 以前有人遇到过这种情况吗? 我想向 WACOM 提交错误报告,但我不知道该告诉他们什么。

我已经能够在我自己的应用程序中重现这一点,该应用程序有一个 JEditorPane,其中包含一个我添加了 HyperlinkListener 的 HTML 文档。 每次使用鼠标单击时,我都会收到 HyperlinkEvent.ACTIVATED 事件,但每次使用笔单击时,我不会收到 HyperlinkEvent.ACTIVATED 事件。

笔和鼠标之间的一大区别是,当您单击鼠标上的按钮时,很容易在不移动鼠标的情况下导致按钮单击。 在数位板上,很难做到这一点,这似乎与缺少 HyperlinkEvent.ACTIVATED 事件相关 - 如果我在点击数位板时非常小心不移动笔位置,我想我可以得到 ACTIVATED事件。

有什么建议可以尝试一下,以便我可以向 WACOM 提供有关此错误的一些有用信息吗? 无法在 Java 应用程序中使用我的笔确实令人沮丧,特别是因为该笔在“常规”Windows(非 Java)应用程序中运行良好。

通常我不会在这里问这个问题,但我想从程序员的角度找出可能发生的情况,以便我可以提交一份好的错误报告。

I've been running up against a problem with Java Swing + my Wacom Graphire tablet for a few years in several Java applications and have now encountered it in my own.

I use a pen tablet to get around wrist issues while clicking a mouse, and it works fine under Windows except when I'm using Java applications. In Java applications, the single-click of the pen doesn't work correctly. (Usually the problem only occurs with file-selection dialog boxes or tree controls.) The pen tablet also comes with a wireless mouse that works with the same tablet, and its single-click does work correctly.

I don't know whether the problem is in the WACOM driver or in the Java Swing runtime for Windows or both. Has anyone encountered this before? I'd like to file a bug report with WACOM but I have no idea what to tell them.

I have been able to reproduce this in my own application that has a JEditorPane with an HTML document that I've added a HyperlinkListener to. I get HyperlinkEvent.ACTIVATED events on every single click with the mouse, but I do NOT get HyperlinkEvent.ACTIVATED events on every single click with the pen.

One big difference between a pen and a mouse is that when you click a button on a mouse, it's really easy to cause the button-click without mouse movement. On the pen tablet it is very hard to do this, and that seems to correlate with the lack of HyperlinkEvent.ACTIVATED events -- if I am very careful not to move the pen position when I tap the tablet, I think I can get ACTIVATED events.

Any suggestions for things to try so I can give WACOM some good information on this bug? It's really frustrating to not be able to use my pen with Java apps, especially since the pen works fine with "regular" Windows (non-Java) applications.

Normally I wouldn't ask this question here but I'd like to find out from a programmer's standpoint what might be going on so I can file a good bug report.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

み零 2024-07-24 07:06:06

我尝试了曼哈顿博士的建议,它很有魅力。 我正确获取 mousePressed/mouseReleased 事件; mouseClicked 事件总是在数位板鼠标上发生,但 mouseClicked 事件不会在笔上发生,除非我设法使笔保持静止。 即使 1 个像素的移动也足以使其失败。 我想我应该将此归咎于 Java:没有办法为可接受的移动指定“点击半径”。

package com.example.bugs;

import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JFrame;

public class WacomMouseClickBug {
    public static void main(String[] args) {
        JFrame jframe = new JFrame();

        jframe.addMouseListener(new MouseListener(){
            @Override public void mouseClicked(MouseEvent event) {
                System.out.println("mouseClicked: "+event);
            }
            @Override public void mouseEntered(MouseEvent event) {}
            @Override public void mouseExited(MouseEvent event) {}
            @Override public void mousePressed(MouseEvent event) {
                System.out.println("mousePressed: "+event);
            }
            @Override public void mouseReleased(MouseEvent event) {
                System.out.println("mouseReleased: "+event);                
            }           
        });

        jframe.setPreferredSize(new Dimension(400,400));        
        jframe.pack();
        jframe.setLocationRelativeTo(null);
        jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jframe.setVisible(true);
    }
}

I tried dr.manhattan's suggestion and it works like a charm. I get mousePressed/mouseReleased events correctly; mouseClicked events happen always with the pen tablet mouse, but mouseClicked events do not happen with the pen unless I manage to keep the pen very still. Even a 1-pixel movement is enough to make it fail. I guess I should blame Java for this one: there's no way to specify a "click radius" for acceptible movement.

package com.example.bugs;

import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JFrame;

public class WacomMouseClickBug {
    public static void main(String[] args) {
        JFrame jframe = new JFrame();

        jframe.addMouseListener(new MouseListener(){
            @Override public void mouseClicked(MouseEvent event) {
                System.out.println("mouseClicked: "+event);
            }
            @Override public void mouseEntered(MouseEvent event) {}
            @Override public void mouseExited(MouseEvent event) {}
            @Override public void mousePressed(MouseEvent event) {
                System.out.println("mousePressed: "+event);
            }
            @Override public void mouseReleased(MouseEvent event) {
                System.out.println("mouseReleased: "+event);                
            }           
        });

        jframe.setPreferredSize(new Dimension(400,400));        
        jframe.pack();
        jframe.setLocationRelativeTo(null);
        jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jframe.setVisible(true);
    }
}
第几種人 2024-07-24 07:06:06

我想您自己已经得到了答案:移动笔会导致一些其他事件,而不是简单的单击,也许是拖放之类的事件。
我不确定这是 Java/Swing 还是 Wacom 问题,可能是平板电脑没有将点击注册为拖动事件,或者可能是 swing 错误地解释了事件。

I think you already got the answer yourself: Moving the pen results in some other event than a simple click, perhaps maybe a Drag and drop like event.
I'm not sure whether it's a Java/Swing or a Wacom problem, it could be that the tablet doesn't register the clicks as such but as drag events, or it could be that swing interprets the events incorrectly.

旧城空念 2024-07-24 07:06:06

我多年前就向 Sun 报告了这个错误。 它仍然没有修复。 任何像样的 ui 框架都将允许在按下和释放之间进行一些移动以生成单击事件。 在高 dpi 显示屏上最大移动 1 像素简直是荒谬的。 这不仅是 wacom 平板电脑的问题,即老年人在点击时也很难保持鼠标静止。

I reported this bug many years ago to Sun. It still is not fixed. Any decent ui framework will allow some movement between a press and release to generate a click event. A maximum movement of 1 pixel on a high dpi display is just ridiculous. It is not only an issue with wacom tablets, ie older people also have difficulties to keep the mouse still when clicking.

悲欢浪云 2024-07-24 07:06:05

您应该做的是添加一个 mouseListener 并查看它何时注册 mouseClicked()、mousePressed()、mouseReleased() /代码> 事件。 我不确定秋千是否将平板笔读取为鼠标。 但是,它应该能让您了解实际情况。

What you should do is add a mouseListener and see when it registers a mouseClicked(), mousePressed(), mouseReleased() event. I'm not sure if the swing reads the tablet pen as a mouse though. However, it should give you some insight into what's actually going on.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文