🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #159

Re: Pre-Selected Button

#159
From: George Xavier
Date: Sat, 06 May 2006 19:26
30 lines
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 
Technical Details
Message-ID: <445cf85e$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <445b7269$1@newsgroups.borland.com> <445b785a$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,30e91bf2bfc69eae
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "George Xavier" <NOgxSPAM@xgeorge.com>
Newsgroups: borland.public.jbuilder.java.swing
References: <445b7269$1@newsgroups.borland.com> <445b785a$1@newsgroups.borland.com>
Subject: Re: Pre-Selected Button
Date: Sat, 6 May 2006 15:26:14 -0400
Lines: 32
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2869
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 70.21.156.33
Message-ID: <445cf85e$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1146943582 70.21.156.33 (6 May 2006 12:26:22 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail