Results 1 to 4 of 4

Thread: addTextListner

  1. #1
    thelinuxguy is offline Member
    Join Date
    Dec 2008
    Posts
    44
    Rep Power
    0

    Default addTextListener

    Hi

    Does anyone know the appropriate syntax for a TextListener. I am trying to add a textListener to a JTextArea but keep getting the following error message:-

    ATM.java:75: cannot find symbol
    symbol : method addTextListener()
    location: class javax.swing.JTextArea
    displayArea.addTextListener();
    Any help would be appreciated. I have the addTextListner method within my class, so I dont think this is causing a problem.

    Sincerely

    theLinuxGuy
    Last edited by thelinuxguy; 02-18-2009 at 05:27 PM. Reason: title mispelling

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    are you sure you didn't mean addDocumentListener? There's no such thing as a textlistener or an addTextListener method for JTextArea.

    When in doubt, read the API.

  3. #3
    thelinuxguy is offline Member
    Join Date
    Dec 2008
    Posts
    44
    Rep Power
    0

    Default addTextListener()

    Hi Fubarable

    Thanks for the reply. I did mean TextListener, it is listed on page 335 of sams teach yourself java 6, and on some sites that I have looked at. I will look at addDocumentListener(), it might be helpful.

    Thanks

    Kind Regards

    theLinuxGuy

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    I don't doubt that page 335 mentions this, but are you sure that it mentions it in reference to JTextAreas? I think that you may be mixing up Swing and AWT here as TextListeners are used with the AWT component TextArea but not with the Swing component JTextArea. Right now I'm standing by your need to use a DocumentListener here not a TextListener, but please look at the fine print of that article and get back to me if I'm wrong.
    Last edited by Fubarable; 02-19-2009 at 12:45 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •