gpt4 book ai didi

java - JFreeChart XYPlot XYImageAnnotation 鼠标点击监听器

转载 作者:行者123 更新时间:2023-11-30 07:38:27 25 4
gpt4 key购买 nike

我有一个带有 2 个子图 (XYPlot) 的 JFreeChart

我有 XYImageAnnotation,我想将其变成按钮,但我找不到监听鼠标点击任何注释的方法。

你知道有什么方法可以做到这一点吗?

最佳答案

I have no idea how to listen [for] click from annotations

在您的 ChartMouseListener 中,您将获得一个 ChartMouseEvent。使用它来获取作为 XYAnnotationEntityChartEntity

chartPanel.addChartMouseListener(new ChartMouseListener() {

@Override
public void chartMouseClicked(ChartMouseEvent cme) {
ChartEntity ce = cme.getEntity();
if (ce instanceof XYAnnotationEntity) {
// handle the click
}
}
}

否则,请查找您添加注释的 XYItemEntity

关于java - JFreeChart XYPlot XYImageAnnotation 鼠标点击监听器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35043299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com