Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By Fubarable

Thread: Disable drag and drop for any text

  1. #1
    fauzeddd- is offline Member
    Join Date
    Jun 2012
    Posts
    3
    Rep Power
    0

    Default Disable drag and drop for any text

    Hi people, I'm here with another problem I've just realised ...

    I programmed my textfield in order to accept only numbers. It does work great, but if I drag some text from any part and drop it into the textfield,
    it accepts it...I was searching on the net and found some helpful information, but just about restricting a textfield to drag something of itself.

    I just want to disable dropping any text into the textfield. Hope you understand and could help me...

    Thanks in advance...

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

    Default Re: Disable drag and drop for any text

    Quote Originally Posted by fauzeddd- View Post
    Hi people, I'm here with another problem I've just realised ...

    I programmed my textfield in order to accept only numbers. It does work great, but if I drag some text from any part and drop it into the textfield,
    it accepts it...I was searching on the net and found some helpful information, but just about restricting a textfield to drag something of itself.

    I just want to disable dropping any text into the textfield. Hope you understand and could help me...
    You may be trying to fix the wrong thing. My question is how did you prevent the textfield from accepting non-numeric input? Did you use a KeyListener? If so and if this is a Swing application, then that's not the way to solve it. Better is to use either a JFormattedTextField or a DocumentFilter.

    Then your field can handle drag and drop or copy and paste, and keypresses.
    DarrylBurke likes this.

Similar Threads

  1. Need help with drag and drop
    By NixasMuraki in forum New To Java
    Replies: 2
    Last Post: 06-07-2011, 01:55 AM
  2. JTable disable drag and drop row
    By NextEpisode1 in forum AWT / Swing
    Replies: 1
    Last Post: 02-10-2011, 06:46 PM
  3. drag and drop - disable intra component drop
    By tomba in forum AWT / Swing
    Replies: 4
    Last Post: 12-09-2009, 01:01 PM
  4. Disable Drag mode of Jinternal Frame
    By smartsubroto in forum New To Java
    Replies: 4
    Last Post: 06-23-2008, 07:21 AM
  5. Replies: 3
    Last Post: 06-07-2007, 05:52 PM

Tags for this Thread

Posting Permissions

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