在Vertex上添加mouseListener

时间:2015-10-28 09:54:06

标签: java jgraphx jgraph

我正在尝试使用Java中的JGraphX制作图表,并在特定类型的顶点上添加mouseListener

我试图使用graphComponent,但它没有做任何事......

这是我的代码:

        mxGraphComponent graphComponent = new mxGraphComponent(graph);

        graphComponent.getGraphControl().addMouseListener( new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
                mxCell cell = (mxCell) graphComponent.getCellAt(e.getX(), e.getY());
                System.out.println("TOTO");

                if(cell != null && cell instanceof mxCell){
                    if(cell.getValue().toString().equals("AAM")){
                        System.out.println("My Cell selected");
                    }

                }
            }
        });

1 个答案:

答案 0 :(得分:1)

您的代码适用于我。尝试这个,它应该100%工作:

date_default_timezone_set("Asia/Colombo");

$dateStart = get_post_meta( get_the_ID(), 'startdate' , true);
$datetime1 = new DateTime(date('Y-m-d', $dateStart));
$datetime2 = new DateTime(date('Y-m-d', $dateStart)));

$interval = $datetime1->diff($datetime2);
$date_diff = $interval->format('%R%a days');

echo "Difference is ".$date_diff