🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: anonymous inner class

#762
From: Alan Shiers
Date: Fri, 17 Dec 2004 17:47
41 lines
2254 bytes
You can ignore this last post...I just figured it out:

JTextField textField = new JTextField();
textField.addActionListener(new ActionListener()
                  {
                     public void actionPerformed(ActionEvent e)
                     {
                       setProperty(propertyName, e.getActionCommand());
                     }
                  });

Alan


"Alan Shiers" <ashiers@hfx.eastlink.ca> wrote in message
news:41c31757$1@newsgroups.borland.com...
> Hi there,
>
> How do I fix this:
>
> static String propertyName = ""; //<<this is set in another method
> private static void setProperty(String property, Object o){...}
> JTextField textField = new JTextField();
>  textField.addActionListener(new ActionListener()
>                   {
>                      public void actionPerformed(ActionEvent e)
>                      {
>                        setProperty(propertyName, getText());  //<<<< The
> compiler doesn't like the call to getText()
>                      }
>                   });
>
> What do I have to change to access the getText() method of JTextField?
> I've tried: this.getText() and JTextField.this.getText()
> Neither one works.
>
> Please advise,
>
> Alan
>
>
Technical Details
Message-ID: <41c31ca2$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!zen.net.uk!dedekind.zen.co.uk!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41c31757$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,55efd19d4eed5bf0
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Alan Shiers" <ashiers@hfx.eastlink.ca>
Newsgroups: borland.public.jbuilder.java.swing
References: <41c31757$1@newsgroups.borland.com>
Subject: Re: anonymous inner class
Date: Fri, 17 Dec 2004 13:47:30 -0400
Lines: 43
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 24.222.101.2
Message-ID: <41c31ca2$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1103305890 24.222.101.2 (17 Dec 2004 09:51:30 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!zen.net.uk!dedekind.zen.co.uk!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail