Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2011
    Location
    Florida
    Posts
    60
    Rep Power
    0

    Default DnD and CCP from non jave apps

    I'm feeling a bit stupid about this topic because I just read the entire tutorial Lesson: Drag and Drop and Data Transfer (The Java™ Tutorials > Creating a GUI With JFC/Swing) and still don't understand how to actually detect the drop or CCP event. I want to be able to simply allow the user to drag or copy, cut, and paste plain text from anywhere (text file, web browser, etc.) to a JTextArea in my app. I understand all in the tutorial except how to actually detect the event. Where is the listener and how do I implement it? I'm using netbeans 6.9.1 and there are no pertinent events listed that I can see.
    Any help would be greatly appreciated.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Have you tried copying one of the examples from the Tutorial and getting it to work?
    What happened?
    If you have problems, post them here.

  3. #3
    Join Date
    Feb 2011
    Location
    Florida
    Posts
    60
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Have you tried copying one of the examples from the Tutorial and getting it to work?
    What happened?
    If you have problems, post them here.
    But I shouldn't have to write a custom transfer handler do I? The dnd and ccp work right out of the box. I can already drag text or cut and paste into my JTextArea already. So all that code is already there, somewhere. All I need to know is what is the String being dropped or pasted and when exactly is it happening.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Does the Document model have listeners or methods you can override for detecting when text is added to a component?

  5. #5
    Join Date
    Feb 2011
    Location
    Florida
    Posts
    60
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Does the Document model have listeners or methods you can override for detecting when text is added to a component?
    Well I can do a getDocument() on my JTextArea component and that has a addDocumentListener. Would that work?

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Yes the interface methods in the listener should be called as appropriate.

  7. #7
    Join Date
    Feb 2011
    Location
    Florida
    Posts
    60
    Rep Power
    0

    Default

    Thanks. I will give that a try and let you know.

  8. #8
    Join Date
    Feb 2011
    Location
    Florida
    Posts
    60
    Rep Power
    0

    Default

    That did the trick! I don't know why I can't find these things on my own. Still learning. Thanks again.

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

Similar Threads

  1. Jave + C#
    By Durden in forum New To Java
    Replies: 7
    Last Post: 05-04-2011, 02:58 PM
  2. jave script where is source code
    By maryjane in forum New To Java
    Replies: 1
    Last Post: 01-15-2011, 02:48 AM
  3. Need Help For Jave Slideshow
    By defanci in forum New To Java
    Replies: 0
    Last Post: 01-06-2011, 07:15 AM
  4. Jave Developers (job Opportunity)
    By tetfernandez in forum Jobs Offered
    Replies: 1
    Last Post: 01-15-2009, 12:25 PM
  5. Replies: 13
    Last Post: 07-31-2008, 05:35 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
  •