Article View: borland.public.jbuilder.java.api
Article #1413Re: repeating the showMessageDialog
From: Jim Wu
Date: Wed, 09 Jan 2002 03:39
Date: Wed, 09 Jan 2002 03:39
48 lines
2397 bytes
2397 bytes
FocusEvent object has a method to identify if the event object is
"temporary" ...
You can add this method in your code ......
"Ant�nio Ferreira" <antonio.ferreira@artesis.co.pt> ���g��l��
news:3bcab15a_2@dnews...
> Hi,
>
> I am having a problem with this code:
>
> jTextField1.addFocusListener(new java.awt.event.FocusAdapter() {
>
> public void focusLost(FocusEvent e) {
if ( e.isTemporary() ) return; // add this line
> int k;
>
> try {
> k = Integer.parseInt(jTextField1.getText());
> if (k < 1) {
> JOptionPane.showMessageDialog(null,
> "You must enter a value greater than zero",
> "Atention",
> JOptionPane.WARNING_MESSAGE);
> jTextField1.requestFocus();
> }
> }catch (NumberFormatException excp) {
> System.out.println(excp.getMessage());
> JOptionPane.showMessageDialog(null,
> "You must enter a numeric value.",
> "Atention",
> JOptionPane.WARNING_MESSAGE);
> jTextField1.requestFocus();
> }
> }
> });
>
> It always executes twice the appropiate showMessageDialog.
> Can anyone explain this strange behavior.
> I appreciate all your help.Thanks,
>
>
> Ant�nio Jos?
> Ferreira
>
>
Technical Details
Message-ID:
<3c3bbb70_2@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!128.230.129.106!news.maxwell.syr.edu!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnewsReferences:
<3bcab15a_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 1089d0,ca11cf111dc9b441 X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2002-01-08 19:48:11 PST Reply-To: "Jim Wu" <jimwu@shinewave.com.tw> From: "Jim Wu" <jimwu@shinewave.com.tw> Newsgroups: borland.public.jbuilder.java.api References: <3bcab15a_2@dnews> Subject: Re: repeating the showMessageDialog Date: Wed, 9 Jan 2002 11:39:25 +0800 Lines: 50 Organization: Shinewave X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: 61.222.153.46 Message-ID: <3c3bbb70_2@dnews> X-Trace: dnews 1010547568 61.222.153.46 (8 Jan 2002 19:39:28 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!128.230.129.106!news.maxwell.syr.edu!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews