如何使用事件监听Java(JFreeChart)中的点击?

发布于 2024-12-17 05:43:22 字数 133 浏览 5 评论 0原文

这是我当前使用的代码:

@Override
public void mouseExited(MouseEvent e) {
    System.out.println("detectado");
}

This is the code I'm currently using:

@Override
public void mouseExited(MouseEvent e) {
    System.out.println("detectado");
}

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

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

发布评论

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

评论(2

兲鉂ぱ嘚淚 2024-12-24 05:43:22

您可以使用 addChartMouseListener() 添加一个 ChartMouseListener 到您的 <代码>图表面板。例如,在 BarChartDemo1,添加以下内容:

chartPanel.addChartMouseListener(new ChartMouseListener() {

    public void chartMouseClicked(ChartMouseEvent e) {
        System.out.println(e.getEntity());
    }

    public void chartMouseMoved(ChartMouseEvent e) {}

});

You can use addChartMouseListener() to add a ChartMouseListener to your ChartPanel. For example, in BarChartDemo1, add the following:

chartPanel.addChartMouseListener(new ChartMouseListener() {

    public void chartMouseClicked(ChartMouseEvent e) {
        System.out.println(e.getEntity());
    }

    public void chartMouseMoved(ChartMouseEvent e) {}

});
忘羡 2024-12-24 05:43:22

要监听点击,您必须检查事件类型。

特别是,您可以重写该

public void mouseClicked(MouseEvent ev) 

方法,该方法是 MouseListeners 接口的一部分。

有关填充示例,请参阅:此链接

To listen for clicks, you must check the type of event.

In particular, you override the

public void mouseClicked(MouseEvent ev) 

method, which is part of the interface for MouseListeners.

For a fill example see : this link

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