문제

I'm reading code from another developer and trying to understand how this code works:

final ChartPanel chartPanel = new ChartPanel(aChart);

chartPanel.addChartMouseListener(new ChartMouseListener() {

   @Override
   public void chartMouseClicked(ChartMouseEvent event) {
      //code
   }

   @Override
   public void chartMouseMoved() {}
});

I know it's basically one long method call, but how exactly does this work? I see a new ChartMouseListener() being instantiated, but what is happening after that?

도움이 되었습니까?

해결책

An anonymous instance of ChartMouseListener having 2 overridden methods is being registered as a listener with the component.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top