I am trying to bring a window to the front, using
inputWin = WindowManager.getWindow(inputImp.getTitle()) print inputImp.getTitle() # verifies that this is the window I want WindowManager.setWindow(inputWin) WindowManager.setCurrentWindow(inputWin) WindowManager.repaintImageWindows() print WindowManager.getActiveWindow() # verifies that the correct title is in fact printed The image does not get put in front, even though the last line confirms that it is the active image. Where have I gone wrong? tnx in advance --aryeh -- Aryeh Weiss Faculty of Engineering Bar Ilan University Ramat Gan 52900 Israel Ph: 972-3-5317638 FAX: 972-3-7384051 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear Aryeh,
I'm almost sure that the macro code selectWindow("name") brings the window in front. And selectWindow("name") corresponds to the "public static void selectWindow(int id)" method of the IJ class. And by looking at its code I see (imp being an ImagePlus element): ImageWindow win = imp.getWindow(); if (win!=null) { win.toFront(); WindowManager.setWindow(win); } At ladt and not at least, "toFront" is from the java.awt.Window class with the following definition "If this Window is visible, brings this Window to the front and may make it the focused Window" within: https://docs.oracle.com/javase/7/docs/api/java/awt/Window.html#toFront() which makes all what I wrote CQFD! Have a nice day. Kindest regards, Philippe Philippe CARL Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie 74 route du Rhin 67401 ILLKIRCH Tel : +33(0)3 68 85 41 84 ----- Mail original ----- De: "aryeh" <[hidden email]> À: "imagej" <[hidden email]> Envoyé: Mercredi 26 Juin 2019 11:01:26 Objet: How to bring a window to the front I am trying to bring a window to the front, using inputWin = WindowManager.getWindow(inputImp.getTitle()) print inputImp.getTitle() # verifies that this is the window I want WindowManager.setWindow(inputWin) WindowManager.setCurrentWindow(inputWin) WindowManager.repaintImageWindows() print WindowManager.getActiveWindow() # verifies that the correct title is in fact printed The image does not get put in front, even though the last line confirms that it is the active image. Where have I gone wrong? tnx in advance --aryeh -- Aryeh Weiss Faculty of Engineering Bar Ilan University Ramat Gan 52900 Israel Ph: 972-3-5317638 FAX: 972-3-7384051 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Aryeh Weiss
Thank you for your quick and correct reply.
It works as advertised. I did not think of going to the awt window class to use those methods. In WindowManager toFront() works on an awt Frame. I also did not think of going to the macro command and then looking at its source. So those are two new things I learned from your reply, in addition to solving the problem. Best regards --aryeh On 26/06/2019 5:37, CARL Philippe (LBP) wrote: > Dear Aryeh, > I'm almost sure that the macro code selectWindow("name") brings the window in front. > And selectWindow("name") corresponds to the "public static void selectWindow(int id)" method of the IJ class. > And by looking at its code I see (imp being an ImagePlus element): > ImageWindow win = imp.getWindow(); > if (win!=null) { > win.toFront(); > WindowManager.setWindow(win); > } > At ladt and not at least, "toFront" is from the java.awt.Window class with the following definition "If this Window is visible, brings this Window to the front and may make it the focused Window" within: > https://docs.oracle.com/javase/7/docs/api/java/awt/Window.html#toFront() > which makes all what I wrote CQFD! > Have a nice day. > Kindest regards, > Philippe > > > Philippe CARL > Laboratoire de Bioimagerie et Pathologies > UMR 7021 CNRS - Université de Strasbourg > Faculté de Pharmacie > 74 route du Rhin > 67401 ILLKIRCH > Tel : +33(0)3 68 85 41 84 > > ----- Mail original ----- > De: "Aryeh Weiss" <[hidden email]> > À: "imagej" <[hidden email]> > Envoyé: Mercredi 26 Juin 2019 11:01:26 > Objet: How to bring a window to the front > > I am trying to bring a window to the front, using > > inputWin = WindowManager.getWindow(inputImp.getTitle()) > print inputImp.getTitle() # verifies that this is the window I want > WindowManager.setWindow(inputWin) > WindowManager.setCurrentWindow(inputWin) > WindowManager.repaintImageWindows() > print WindowManager.getActiveWindow() # verifies that the correct > title is in fact printed > > The image does not get put in front, even though the last line confirms > that it is the active image. > Where have I gone wrong? > > tnx in advance > > --aryeh > -- Aryeh Weiss Faculty of Engineering Bar Ilan University Ramat Gan 52900 Israel Ph: 972-3-5317638 FAX: 972-3-7384051 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear Aryeh,
I'm very happy that my step by step demonstration helped you (and hopefully other people on this list) to understand one of the functions research process I often use. And reading at your answer I would like to make two additions. So first the link between a macro code and its corresponding java code can be found within the ij.macro.Functions.java file. Also for the toFront() method, I didn't look within the awt classes (at least at first). But having found the code ImageWindow win = imp.getWindow(); win.toFront(); I looked at the API of the ImageJ ImageWindow class under: https://imagej.nih.gov/ij/developer/api/ij/gui/ImageWindow.html and there it told me that the toFront() method is inherited from the awt classes. At last, CQFD translates in English (or I should rather say in Latin) by QOD for Quod Erat Demonstrandum. Kindest regards, Philippe ----- Mail original ----- De: "aryeh" <[hidden email]> À: "CARL Philippe (LBP)" <[hidden email]>, "imagej" <[hidden email]> Envoyé: Mercredi 26 Juin 2019 12:56:45 Objet: Re: How to bring a window to the front Thank you for your quick and correct reply. It works as advertised. I did not think of going to the awt window class to use those methods. In WindowManager toFront() works on an awt Frame. I also did not think of going to the macro command and then looking at its source. So those are two new things I learned from your reply, in addition to solving the problem. Best regards --aryeh On 26/06/2019 5:37, CARL Philippe (LBP) wrote: > Dear Aryeh, > I'm almost sure that the macro code selectWindow("name") brings the window in front. > And selectWindow("name") corresponds to the "public static void selectWindow(int id)" method of the IJ class. > And by looking at its code I see (imp being an ImagePlus element): > ImageWindow win = imp.getWindow(); > if (win!=null) { > win.toFront(); > WindowManager.setWindow(win); > } > At ladt and not at least, "toFront" is from the java.awt.Window class with the following definition "If this Window is visible, brings this Window to the front and may make it the focused Window" within: > https://docs.oracle.com/javase/7/docs/api/java/awt/Window.html#toFront() > which makes all what I wrote CQFD! > Have a nice day. > Kindest regards, > Philippe > > > Philippe CARL > Laboratoire de Bioimagerie et Pathologies > UMR 7021 CNRS - Université de Strasbourg > Faculté de Pharmacie > 74 route du Rhin > 67401 ILLKIRCH > Tel : +33(0)3 68 85 41 84 > > ----- Mail original ----- > De: "Aryeh Weiss" <[hidden email]> > À: "imagej" <[hidden email]> > Envoyé: Mercredi 26 Juin 2019 11:01:26 > Objet: How to bring a window to the front > > I am trying to bring a window to the front, using > > inputWin = WindowManager.getWindow(inputImp.getTitle()) > print inputImp.getTitle() # verifies that this is the window I want > WindowManager.setWindow(inputWin) > WindowManager.setCurrentWindow(inputWin) > WindowManager.repaintImageWindows() > print WindowManager.getActiveWindow() # verifies that the correct > title is in fact printed > > The image does not get put in front, even though the last line confirms > that it is the active image. > Where have I gone wrong? > > tnx in advance > > --aryeh > -- Aryeh Weiss Faculty of Engineering Bar Ilan University Ramat Gan 52900 Israel Ph: 972-3-5317638 FAX: 972-3-7384051 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |