Drag and Drop from System to Java

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dominic

    Drag and Drop from System to Java

    Hi,

    I'm writing a program to accept dragging files from the OS (I'm using
    Windows) to my Java application. Everything works fine, excpet that the Java
    window cannot get the focus when drag enter/over. I tried to put

    frame.requestFo cus();

    in my DropTargetListe ner, but it still doesn't get the focus. I'm sure that
    the code is being processed (I changed it to setVisible(fals e) and it
    works!). So is it a constraint of Windows or what? Thanks.

    --



  • Philip Barr

    #2
    Re: Drag and Drop from System to Java

    In the api it says this:

    "Because the focus behavior of this method is platform-dependent, developers
    are strongly encouraged to use requestFocusInW indow when possible."

    .......don't know if that'll help?


    "dominic" <dominickwan@so fthome.net> wrote in message
    news:bga6b0$m0q 4@imsp212.netvi gator.com...[color=blue]
    > Hi,
    >
    > I'm writing a program to accept dragging files from the OS (I'm using
    > Windows) to my Java application. Everything works fine, excpet that the[/color]
    Java[color=blue]
    > window cannot get the focus when drag enter/over. I tried to put
    >
    > frame.requestFo cus();
    >
    > in my DropTargetListe ner, but it still doesn't get the focus. I'm sure[/color]
    that[color=blue]
    > the code is being processed (I changed it to setVisible(fals e) and it
    > works!). So is it a constraint of Windows or what? Thanks.
    >
    > --
    >
    >
    >[/color]


    Comment

    • dominic

      #3
      Re: Drag and Drop from System to Java

      The result is still the same : (
      In the dragOver function I used requestFocusInW indow(), and it returns true
      but the window doesn't really get the focus.

      But thanks anyway!

      --


      "Philip Barr" <philb@blueyond er.co.uk> wrote in message
      news:YRcWa.1078 3$1n6.2122@news-binary.blueyond er.co.uk...[color=blue]
      > In the api it says this:
      >
      > "Because the focus behavior of this method is platform-dependent,[/color]
      developers[color=blue]
      > are strongly encouraged to use requestFocusInW indow when possible."
      >
      > ......don't know if that'll help?
      >
      >[/color]


      Comment

      • Neomorph

        #4
        Re: Drag and Drop from System to Java

        On Fri, 1 Aug 2003 10:25:05 +0800, "dominic" <dominickwan@so fthome.net>
        two-finger typed:
        [color=blue]
        >The result is still the same : (
        >In the dragOver function I used requestFocusInW indow(), and it returns true
        >but the window doesn't really get the focus.
        >
        >But thanks anyway![/color]

        If you're using Swing components, you may try to use the
        javax.swing.Swi ngUtilities.inv okeLater() method to do the requestFocus
        asynchronously, after all events have been processed.

        Cheers.

        Comment

        • SPC

          #5
          Re: Drag and Drop from System to Java

          Admittedly, I was dragging between frames in my own app, but I found
          that this forced the frame to the top...
          Window w = SwingUtilities. getWindowAncest or(HierarchyPan e.this);
          if (w != null) {
          w.show();
          }

          In the dragEnter method of my dropTargetListe ner.

          HTH

          Steve

          Comment

          • dominic

            #6
            Re: Drag and Drop from System to Java

            Thanks all! This works fine now.

            Dominic

            --


            "SPC" <steve@scholl.d emon.co.uk> wrote in message
            news:aa6c6bcb.0 308010650.2f065 294@posting.goo gle.com...[color=blue]
            > Admittedly, I was dragging between frames in my own app, but I found
            > that this forced the frame to the top...
            > Window w = SwingUtilities. getWindowAncest or(HierarchyPan e.this);
            > if (w != null) {
            > w.show();
            > }
            >
            > In the dragEnter method of my dropTargetListe ner.
            >
            > HTH
            >
            > Steve[/color]


            Comment

            Working...