Hi,
I'm building a GUI for my plugin and I've just realised I could achieve quite a bit with the GenericDialog if I could set the captions of the Yes and No buttons. In my case, I want the no button to say "Add another file" and the yes button to say "Run batch". I think this is a very simple way of making the generic dialog more versatile. So would it be possible to add two more functions to the GenericDialog class? Kind regards, Eirinn _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Eirinn Mackay Research Assistant Bartlett Group L6 Queensland Brain Institute Brisbane, Australia 07 334 66381 |
Hi Eirinn,
GenericDialog has a public void setOKLabel(String label) method that you can use. There is nothing like this for 'cancel' Misusing 'Cancel' for something else may also have unwanted side effects, e.g., aborting a macro on gd.wasCanceled(). Pprobably you will need a 'cancel' button anyhow, e.g., in case the user finds out that he has added the wrong file. If you really don't want it, use the public void hideCancelButton() method. You will have to add a panel for the "Add file" button, and your plugin should be an ActionListener to that button. ij.plugin.LUT_Editor is an example for this. If you want to run it from a macro, you will have to care about the operation of the 'add file' button for yourself; GenericDialog won't do it for you (in contrast to the other input types). Michael ________________________________________________________________ On 2 Jul 2009, at 03:25, Eirinn Mackay wrote: > Hi, > I'm building a GUI for my plugin and I've just realised I could > achieve quite a bit with the GenericDialog if I could set the > captions of the Yes and No buttons. In my case, I want the no > button to say "Add another file" and the yes button to say "Run > batch". I think this is a very simple way of making the generic > dialog more versatile. > So would it be possible to add two more functions to the > GenericDialog class? > Kind regards, > Eirinn > _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > Eirinn Mackay > Research Assistant > Bartlett Group L6 > Queensland Brain Institute > Brisbane, Australia > 07 334 66381 |
In reply to this post by Eirinn Mackay
> Hi,
> I'm building a GUI for my plugin and I've just realised I could > achieve quite a bit with the GenericDialog if I could set the captions > of the Yes and No buttons. In my case, I want the no button to say > "Add another file" and the yes button to say "Run batch". I think this > is a very simple way of making the generic dialog more versatile. > So would it be possible to add two more functions to the GenericDialog > class? The GenericDialog class in the v1.43c daily build adds a enableYesNoCancel(yesLabel, noLabel) method. Here is an example that shows how to use it: GenericDialog gd = new GenericDialog("YesNoCancel Demo"); gd.addMessage("This is a custom YesNoCancel dialog"); gd.enableYesNoCancel("Run batch", "Add another file"); gd.showDialog(); if (gd.wasCanceled()) IJ.log("The user clicked on the 'Cancel' button"); else if (gd.wasOKed()) IJ. log("The user clicked on the 'Yes' button"); else IJ. log("The user clicked on the 'No' button"); -wayne |
That's great!
This is one of the reasons i've choosen IJ as a development platform. IJ has been dialy updated indeed and, when a good suggestion appears, it's fastly added to IJ. Congratulations to Wayne and others IJ developers. Best Regards, Fernando Sales _____________________________________________________ Electronic Engineer, PhD Student - Biomedical Engineering Heart Institute (InCor) - University of Sao Paulo Medical School Informatics Division - InCor Av. Enéas de Carvalho Aguiar, 44 ZIP:05403-000 São Paulo- SP-Brazil Tel.: 55-11-3069-5545 Fax : 55-11-3069-5311 http://lattes.cnpq.br/2763370548436903 _____________________________________________________ On Thu, Jul 2, 2009 at 11:04 AM, Wayne Rasband <[hidden email]> wrote: > Hi, >> I'm building a GUI for my plugin and I've just realised I could achieve >> quite a bit with the GenericDialog if I could set the captions of the Yes >> and No buttons. In my case, I want the no button to say "Add another file" >> and the yes button to say "Run batch". I think this is a very simple way of >> making the generic dialog more versatile. >> So would it be possible to add two more functions to the GenericDialog >> class? >> > > The GenericDialog class in the v1.43c daily build adds a > enableYesNoCancel(yesLabel, noLabel) method. Here is an example that shows > how to use it: > > GenericDialog gd = new GenericDialog("YesNoCancel Demo"); > gd.addMessage("This is a custom YesNoCancel dialog"); > gd.enableYesNoCancel("Run batch", "Add another file"); > gd.showDialog(); > if (gd.wasCanceled()) > IJ.log("The user clicked on the 'Cancel' button"); > else if (gd.wasOKed()) > IJ. log("The user clicked on the 'Yes' button"); > else > IJ. log("The user clicked on the 'No' button"); > > -wayne > -- ************************************************** Fernando José Ribeiro Sales ************************************************** Email: [hidden email] Tel: (11) 82020303 ************************************************** |
In reply to this post by Wayne Rasband
Perfect, thanks Wayne :)
Michael: I knew about setOKlabel, but that only works if you have two buttons, OK and Cancel. With the new function that Wayne wrote, we can now have an extra button without the complexity of adding a panel. For example, one could have "OK", "Cancel", and "Browse...". Cheers, Eirinn _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Eirinn Mackay Research Assistant Bartlett Group L6 Queensland Brain Institute Brisbane, Australia 07 334 66381 On 03/07/2009, at 12:04 AM, Wayne Rasband wrote: >> Hi, >> I'm building a GUI for my plugin and I've just realised I could >> achieve quite a bit with the GenericDialog if I could set the >> captions of the Yes and No buttons. In my case, I want the no >> button to say "Add another file" and the yes button to say "Run >> batch". I think this is a very simple way of making the generic >> dialog more versatile. >> So would it be possible to add two more functions to the >> GenericDialog class? > > The GenericDialog class in the v1.43c daily build adds a > enableYesNoCancel(yesLabel, noLabel) method. Here is an example that > shows how to use it: > > GenericDialog gd = new GenericDialog("YesNoCancel Demo"); > gd.addMessage("This is a custom YesNoCancel dialog"); > gd.enableYesNoCancel("Run batch", "Add another file"); > gd.showDialog(); > if (gd.wasCanceled()) > IJ.log("The user clicked on the 'Cancel' button"); > else if (gd.wasOKed()) > IJ. log("The user clicked on the 'Yes' button"); > else > IJ. log("The user clicked on the 'No' button"); > > -wayne |
Free forum by Nabble | Edit this page |