When doing Drag and Drop in Java 1.6 some of the Data in my Custom source class is not available in my ImportData method.

Posted on 2007-07-30
Last Modified: 2013-12-29
I am attempting to do Drag and Drop using Java 1.6.  I have written a class that extends TransferHandler.  I have a custom class that I am wrapping the Transferable around.  It has as a member variable another custom class that I can get using a getter method.  Some of the data from the custom class is not there in my importData method including the custom subclass when I call its getter method.  Can anyone tell me why some of the data associated with my source custom class is not available in my importData method?  I have looked at the links to the tutorials and they do not have examples that deal with this situation.

Question by:gdkinney_2
    LVL 23

    Expert Comment

    Sorry to say this but the question is not very clear please provide the code snippets.

    I think this has nothing to do with Drag drop as such it seems to be some scoping issue of the classes.

    Author Comment

    Actually I think I solved the problem of some data not getting to the importData method in the class that extends TransferHandler.  Some of the members in the class were transient and that kept them from being available in the importData method.  

    I have another question though is it possible using the Drag and Drop APIs to have a source class for Drag and Drop that does not descend from JComponent.  The exportAsDrag method in the TransferHandler class that initiates the Drag procedure is as follows:       
    exportAsDrag(JComponent comp, InputEvent e, int action)

    so it could not be called to initate the drag when the source class does not descend from JComponent.  In that case when the source class does not descend from JComponent how would you initiate the Drag operation in 1.6 Drag and Drop?
    LVL 23

    Accepted Solution

    I don't think there are any visual components which do not descend from JComponent.

    All components in Swing like JLabel, JPanel all are Jcomponets

    Class JComponent

      extended by java.awt.Component
          extended by java.awt.Container
              extended by javax.swing.JComponent

    All Implemented Interfaces:
        ImageObserver, MenuContainer, Serializable

    Direct Known Subclasses:
    AbstractButton, BasicInternalFrameTitlePane, Box, Box.Filler, JColorChooser, JComboBox, JFileChooser, JInternalFrame, JInternalFrame.JDesktopIcon, JLabel, JLayeredPane, JList, JMenuBar, JOptionPane, JPanel, JPopupMenu, JProgressBar, JRootPane, JScrollBar, JScrollPane, JSeparator, JSlider, JSpinner, JSplitPane, JTabbedPane, JTable, JTableHeader, JTextComponent, JToolBar, JToolTip, JTree, JViewport


    If you had meant some thing like draging a file on to some visual component then check this
    LVL 1

    Expert Comment

    Forced accept.

    EE Admin

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now