🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Default Push Button

#11061
From: wim.van.leuven
Date: Tue, 13 Jul 1999 00:00
38 lines
1923 bytes
In article <7m5lpe$kmp2@forums.borland.com>,
  "Scott Broderhausen" <sbroder@xylan.com> wrote:
> I am new to Java and am very used to the way the windows sdk handled
> dialogs.  I want to have a default push button for my OK button.  I
found
> the setDefaultButton() call and it does make the OK button look like a
> default push button but when I try to run the dialog and press the
enter key
> nothing happens.  If the OK button has the focus then it works.
However,
> the point of a default push button is to be able to hit the enter key
> without making the default button have the focus.  What do I need to
do to
> get this to work properly?
>
> Scott
>
>

Scott,

The problem is that at the moment you press enter, the focus probably
is inside some sort of text field (JTextField, JEditorPane or some
other stuff). Now, these type of fields capture the enter key press
event and handle it. If you don't need enter, you should unregister
this keyboard action from the text field. You can do this for one
textfield or all. See the java reference documentation of the class
JTextField to find out how this is done.

Hope to be of any help.

Cheers,

Wim Van Leuven.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Technical Details
Message-ID: <7mf65t$fms$1@nnrp1.deja.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7m5lpe$kmp2@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,c4ef4341a8cc789d
X-Google-Attributes: gid111d45,public
From: wim.van.leuven@watco.be
Subject: Re: Default Push Button
Date: 1999/07/13
Message-ID: <7mf65t$fms$1@nnrp1.deja.com>
X-Deja-AN: 500457607
References: <7m5lpe$kmp2@forums.borland.com>
X-Http-Proxy: 1.0 x29.deja.com:80 (Squid/1.1.22) for client 193.74.148.91
Organization: Deja.com - Share what you know. Learn what you don't.
X-Article-Creation-Date: Tue Jul 13 10:59:12 1999 GMT
Newsgroups: borland.public.jbuilder.java.swing
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)