java mouselistener windows xp 和 mac os 的区别
我正在实现一个 Java Swing GUI,它有几个 JLabel,它们在 JFrame 上显示几次。因此,我实例化了标签并将它们存储在向量中。对于每个标签,我在 JFrame 扩展类的构造函数中添加了一个这样的侦听器:
b1.addMouseListener(new LabelMouseListener(...));
每次我想要显示标签时,我都会从向量中选取它们并将它们添加为框架上的组件。这很好用。而且,我在构造函数中添加的侦听器正在侦听。但是,Mac 和 PC 上的行为有所不同。在 Mac 上,它工作得很好,但在 PC (Win XP) 上,我需要单击标签两次,听众才会做出反应。 LabelMouseListener 实现了 MouseListener,我重写了 mouseClicked 方法。也许这也取决于JavaRE,因为在Mac上我使用1.6,在Win上我使用1.7。这是一个已知问题,或者您对错误原因有什么建议吗?
I'm implementing a Java Swing GUI which has a couple of JLabels, who are displayed a few times on a JFrame. For this reason I instanced the labels and stored them in a Vector. For each of the labels I added a listener like this in the constructor of my JFrame extending class:
b1.addMouseListener(new LabelMouseListener(...));
Every time I want to display the labels, I pick them from the vector and add them as a component on the frame. This works fine. And also, the listener, I added in the constructor is listening. But, there is a difference between the behavior on a Mac and on a PC. On a Mac it works completely fine, but on a PC (Win XP) I need to click the label twice before the listener reacts.
The LabelMouseListener implements MouseListener and I override the mouseClicked method. Maybe it also depends on the JavaRE, because on the Mac I use the 1.6, on the Win, I use 1.7. Is this a known problem, or do you have any suggestions for the cause of the error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论