🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
2 messages
2 total messages Started by Alan Shiers Fri, 17 Dec 2004 17:24
anonymous inner class
#761
Author: Alan Shiers
Date: Fri, 17 Dec 2004 17:24
23 lines
1566 bytes
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
Re: anonymous inner class
#762
Author: 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
>
>
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