import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; public class ClickSwapImageEvent extends MouseAdapter { private ImageWindow window; public ClickSwapImageEvent(ImageWindow window) { this.window = window; } public void mouseClicked(MouseEvent event) { if(event.getX() > this.window.getWidth() / 2) { this.window.nextImage(); return; } this.window.lastImage(); } }