Setting the focus on a Choice

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Setting the focus on a Choice

CARL Philippe (LBP)
Dear all,
Within a GenericDialog, I would like to set the focus on a given Choice within the Dialog when it gets displayed.
And browsing through forums, I managed to perform this using the following code:
        Vector choices = gd.getChoices();
        final Choice myChoice = (Choice)(choices.elementAt(2));
        gd.addWindowListener( new WindowAdapter()
        {
                public void windowOpened( WindowEvent e )
                {
                        myChoice.requestFocusInWindow();
                }
        });
        gd.showDialog();
which seems nevertheless quite complicated to me.
Thus did I miss something and could such a job be done more easily?
Thanks a lot in advance for your replies on this and have a nice evening,
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 42 89

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html