• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Drag and drop a textbox.

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is is possible to drag and drop a jtextbox in another application like MS word?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The text from the textbox or the actual textbox component? Text, yes, definitely... the actual textbox component... maybe... But if so it would take quite a bit of work... you'd have to do some kind of JavaBeans/ActiveX bridge stuff in the drag and drop so that MS Word would recognize the JTextBox. I've never done this myself, but :
  • I'm pretty sure MS Word allows you to drop (or paste) ActiveX components into documents.
  • I know that the JavaBeans API has a JavaBeans/ActiveX bridge so that you can wrap your JavaBean in an ActiveX wrapper so that it can be treated like an ActiveX component by applications that use ActiveX.
  • All Swing components, including JTextArea, are JavaBean components.

  •  
    Riddhi Shah
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I want to drag a textbox or in that case, any kind of JComponent. I came across this code that drops a label on the word document.
    JLabel label6 = new JLabel(new ImageIcon(im));
    label6.setTransferHandler(new ImageSelection());
    getContentPane().add(label6, BorderLayout.CENTER);
    label6.addMouseListener(mouseListener);
    MouseListener mouseListener = new MouseAdapter() {
    public void mousePressed(MouseEvent e) {
    if (e.getButton() != 3)
    {
    JComponent jc = (JComponent) e.getSource();
    TransferHandler th = jc.getTransferHandler();
    th.exportAsDrag(jc, e, TransferHandler.COPY);
    }
    else
    {
    Point start = e.getPoint();
    copyPopup.show((Component)e.getSource(),start.x,start.y);
    }

    }
    };
    I tried to do the same for Jtextbox and it did not seem to work.
    I will look into JavaBean API and see if I can make that work.
    Thanks.
     
    Nathan Pruett
    Bartender
    Posts: 4121
    IntelliJ IDE Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    The code you posted just transfers the image on the component... not the actual component itself.
     
    Riddhi Shah
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Now I understand what you mean. Till now I was under the confusion that if this code can drag and drop JLabel then why can't it drag and drop a textbox. But I realized that its just the image that is being dragged and not the label.
    I will look in the Java Bean API for more details regarding DnD of Swing Components.
    I will get back with you for more guidance.
    Thanks.
     
    Riddhi Shah
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Nathan,
    I downloaded BDK1.1 on my machine. I have never used it before.
    Can you plese help me figure out how to proceed futher so that this will help me drag and drop a textbox on MS Word?
    Need your help.
    Thanks.
     
    Nathan Pruett
    Bartender
    Posts: 4121
    IntelliJ IDE Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I don't think you need to get the BDK... all Swing components are JavaBean components already... you just need to somehow make Word think they are ActiveX components when they are dropped in. I searched for "JavaBeans ActiveX bridge" and found this link... which looks like it worked in JDK 1.1 through 1.3.1 and they are updating it in JDK 1.4.2. Though it does mention Word specifically on the page, so it looks like it may be the way to go... I also found this JavaWorld article that gives a tutorial on it.

    Though it looks like there may be a lot of versioning problems with this... the old JavaBeans ActiveX bridge worked in JDK 1.1 - 1.3.1. A new one will work in JDK 1.4.2. And it looks like you have to register each bean as an ActiveX component on each computer you are going to use it on. This might be good for a custom solution to something, but I don't see it as a really good portable solution. (But it's probably the only solution anyway...)
     
    Riddhi Shah
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Nathan,
    I really appreciate your help. It has given me some direction to do some more research.
    I also wanted to let you know that we are using JDK1.4.0_03. The article says that the bridge has worked till JDK1.3.1 and will work from JDK1.4.2. I was just curious to know if this would work for JDK 1.4.0_03.
    I will do some more research on this. But as I had also told earlier, I will get back to you for more help.
    Thanks again, I really appreciate your help.
     
    Nathan Pruett
    Bartender
    Posts: 4121
    IntelliJ IDE Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I don't know... the JavaBean/ActiveX bridge wasn't included in JDK 1.4.0, but maybe you could get the one from 1.3.1 and see if it worked with 1.4.0 code. I would think that it probably would... as long as you didn't use any classes added after 1.3.1.
     
    Riddhi Shah
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thank you for all your help.
    I am using JDK 1.4.0_03 - for dragging and dropping an image in my application. I think this functionality is not a part of JDK1.3.
    My question is:
    1) How can I incorporate JavaBean Bridge for Active X Contorl in my java code (in my application?).
    2) Is it true that a person who wants to achieve this functionality(drag and drop textbox from application) should have this bridge installed on his machine? I mean is it true that the end-user has to have this bridge installed on his machine inorder to use this application?
    It would be a great help if you could get back with me.
    Looking forward to recieving your reply.
    reply
      Bookmark Topic Watch Topic
    • New Topic