I'm not sure if this is what you're asking, but this was working for me:
final WorldWindowGLCanvas aCanvas = new WorldWindowGLCanvas();
aCanvas.setModel(new BasicModel());
aCanvas.getInputHandler().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent pE) {
Position aCurrentPosition = aCanvas.getCurrentPosition();
//Or whatever work:
if(aCurrentPosition != null) {
System.out.println("Current Pos= " + aCurrentPosition);
} else {
System.out.println("Current Pos is null!");
}
}
});
I added the null check to see if it would ever get null and it did not. The assumption this code is making is that a mouse click will re-center the globe to that position. Calling the aCanvas.getCurrentPosition() should return the center globe. If the canvas is not rendered or isn't visible, then this method would return null.