Skip to content

Commit

Permalink
correct bug
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Nov 22, 2024
1 parent 5829764 commit 35ba0d0
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/main/java/ai/nets/samj/ij/ui/Consumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,31 +163,29 @@ public void exportImageLabeling() {

@Override
public void activateListeners() {
System.out.println("mm");
if (registered) return;
SwingUtilities.invokeLater(() -> {
activeCanvas.addMouseListener(this);
activeCanvas.addKeyListener(this);
activeWindow.addWindowListener(this);
activeWindow.addKeyListener(this);
activeCanvas.addMouseListener(this);
activeCanvas.addKeyListener(this);
activeWindow.addWindowListener(this);
activeWindow.addKeyListener(this);

activeCanvas.removeKeyListener(IJ.getInstance());
activeWindow.removeKeyListener(IJ.getInstance());
});
activeCanvas.removeKeyListener(IJ.getInstance());
activeWindow.removeKeyListener(IJ.getInstance());
registered = true;
}

@Override
public void deactivateListeners() {
if (!registered) return;
SwingUtilities.invokeLater(() -> {
activeCanvas.removeMouseListener(this);
activeCanvas.removeKeyListener(this);
activeWindow.removeWindowListener(this);
activeWindow.removeKeyListener(this);

activeWindow.addKeyListener(IJ.getInstance());
activeCanvas.addKeyListener(IJ.getInstance());
});
System.out.println(activeCanvas == null);
activeCanvas.removeMouseListener(this);
activeCanvas.removeKeyListener(this);
activeWindow.removeWindowListener(this);
activeWindow.removeKeyListener(this);

activeWindow.addKeyListener(IJ.getInstance());
activeCanvas.addKeyListener(IJ.getInstance());
registered = false;
}

Expand Down Expand Up @@ -215,10 +213,10 @@ public void windowClosed(WindowEvent e) {
roiManager.close();
this.selectedModel.closeProcess();
this.selectedModel = null;
this.deactivateListeners();
this.activeImage = null;
this.activeCanvas = null;
this.activeWindow = null;
this.deactivateListeners();
}


Expand Down

0 comments on commit 35ba0d0

Please sign in to comment.