Thread View: borland.public.jbuilder.java.swing
3 messages
3 total messages
Started by Magnus
Fri, 05 May 2006 15:42
Pre-Selected Button
Author: Magnus
Date: Fri, 05 May 2006 15:42
Date: Fri, 05 May 2006 15:42
12 lines
1349 bytes
1349 bytes
Hi all, I have a login window with 2 fields (Login & Password) and an OK-Button. The user would like to have the OK-Button pre-selected (marked with a border or something) and when Enter is pressed the button will be "pressed". I could add a listener on each text-field but is that the way to go here? How do I get the border or other marking of the pre-selected button? Any and all help is much appreciated, Magnus
Re: Pre-Selected Button
Author: Magnus
Date: Fri, 05 May 2006 16:07
Date: Fri, 05 May 2006 16:07
19 lines
1527 bytes
1527 bytes
Simpler then expected :) I put: getRootPane().setDefaultButton(okButton); after the call to jbInit(); in my constructor. Magnus wrote: > Hi all, > > I have a login window with 2 fields (Login & Password) and an OK-Button. > The user would like to have the OK-Button pre-selected (marked with a > border or something) and when Enter is pressed the button will be > "pressed". > > I could add a listener on each text-field but is that the way to go > here? How do I get the border or other marking of the pre-selected button? > > Any and all help is much appreciated, > > Magnus
Re: Pre-Selected Button
Author: George Xavier
Date: Sat, 06 May 2006 19:26
Date: Sat, 06 May 2006 19:26
30 lines
1966 bytes
1966 bytes
dialog.getRootPane().setDefaultButton(okButton) will ensure that when you press the ENTER key, your event handler for the OK button will be executed. Of course, this is presuming that your dialog does not contain a JTextArea that could be having focus when you press the ENTER key. But I should think that would be unlikely for a login dialog :-) George "Magnus" <magnus_bjorkman@yahoo.com> wrote in message news:445b785a$1@newsgroups.borland.com... > Simpler then expected :) > > I put: getRootPane().setDefaultButton(okButton); > after the call to jbInit(); in my constructor. > > Magnus wrote: >> Hi all, >> >> I have a login window with 2 fields (Login & Password) and an OK-Button. >> The user would like to have the OK-Button pre-selected (marked with a >> border or something) and when Enter is pressed the button will be >> "pressed". >> >> I could add a listener on each text-field but is that the way to go here? >> How do I get the border or other marking of the pre-selected button? >> >> Any and all help is much appreciated, >> >> Magnus
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads